Skip to content

Conversation

@Lucien950
Copy link
Contributor

No description provided.

Copy link
Contributor Author

@Lucien950 Lucien950 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

few small things to look at, reiteration of things we discussed on saturday

Comment on lines +31 to +40
switch chosenTemp
case 80
dat = load('A2370DD_T80C.mat');
case 100
dat = load('A2370DD_T100C.mat');
case 120
dat = load('A2370DD_T120C.mat');
otherwise
error('Unexpected temperature selection.');
end
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

load seperately

error('Unexpected temperature selection.');
end

notes = {};
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

previously discussed notes method

Comment on lines +27 to +29
availableTemps = [80 100 120];
[~, idxNearest] = min(abs(availableTemps - Temp));
chosenTemp = availableTemps(idxNearest);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

later interpolation?

% Derive speed and current axes from matrix dimensions:
% assume speeds from 0 to 20000 rpm across NR rows (uniform)
% assume currents from 0 to 105 A across NC columns (uniform)
speeds = linspace(0,20000,NR).'; % column vector, rpm
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

take speed as input (as previously discussed)

Comment on lines +82 to +85
% Check voltage satisfied (with tolerance)
v_ok = (Vv <= V_dc + epsV);
% Check torque satisfied (with tolerance downward)
t_ok = (Tv >= T_dmd - epsT);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

personal preference but write it as |x-y| <= eps

Comment on lines +78 to +110
for row = NR:-1:1 % highest speed first
for col = 1:NC % lowest current first
Tv = Tmat(row,col);
Vv = Vmat(row,col);
% Check voltage satisfied (with tolerance)
v_ok = (Vv <= V_dc + epsV);
% Check torque satisfied (with tolerance downward)
t_ok = (Tv >= T_dmd - epsT);
if v_ok && t_ok
% Exact acceptable operating point found (prefer high RPM, then low current)
selected_row = row;
selected_col = col;
found_exact = true;
notes{end+1} = sprintf('Exact operating point found at row %d (%.1f rpm), col %d (I=%.3g A): T=%.3g, V=%.3g.', ...
row, speeds(row), col, currents(col), Tv, Vv);
break; % break inner loop (we found the best point for this high RPM)
else
% If voltage satisfied but torque not, consider as fallback candidate
if v_ok && ~t_ok
if Tv > fallback_T
fallback_T = Tv;
fallback_row = row;
fallback_col = col;
fallback_exists = true;
end
end
% Otherwise (V not ok) we do nothing special, continue scanning
end
end
if found_exact
break; % exit outer loop
end
end
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you can replace this with (assuming dimensions of Vmat, Tmat are the same)

Suggested change
for row = NR:-1:1 % highest speed first
for col = 1:NC % lowest current first
Tv = Tmat(row,col);
Vv = Vmat(row,col);
% Check voltage satisfied (with tolerance)
v_ok = (Vv <= V_dc + epsV);
% Check torque satisfied (with tolerance downward)
t_ok = (Tv >= T_dmd - epsT);
if v_ok && t_ok
% Exact acceptable operating point found (prefer high RPM, then low current)
selected_row = row;
selected_col = col;
found_exact = true;
notes{end+1} = sprintf('Exact operating point found at row %d (%.1f rpm), col %d (I=%.3g A): T=%.3g, V=%.3g.', ...
row, speeds(row), col, currents(col), Tv, Vv);
break; % break inner loop (we found the best point for this high RPM)
else
% If voltage satisfied but torque not, consider as fallback candidate
if v_ok && ~t_ok
if Tv > fallback_T
fallback_T = Tv;
fallback_row = row;
fallback_col = col;
fallback_exists = true;
end
end
% Otherwise (V not ok) we do nothing special, continue scanning
end
end
if found_exact
break; % exit outer loop
end
end
[n, m] = size(Vmat)
k = find(abs(Vmat - T_dmd) <= epsT & abs(Vmat - V_dc) <= epsV, 1, 'first')
found_exact=size(k) > 0
row, col = mod(k[0], n), floorDiv(k[0] / n)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(double check my syntax but this is the main idea)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants