Error: Class member redefinition has been found
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
I have been trying to define a resistor which also produces heat in simscape. The code for the .ssc file is depicted below. When I try to insert the component (via library browser: simscape/utilities/simscape component), I get the error: " Error: Class member redefinition has been found." and "Caused by:
Error using MyPackage.heat_producing_resistor> (line 10)
Class member 'h' is defined.
Error using MyPackage.heat_producing_resistor> (line 16)
Class member 'h' is defined"
What is the problem?
Am i not authorised to define an output?
Is the fault in foundation.electrical.electrical(I don`t understad what that means and if it should be defined differently and why)?
Thanks in advance
component heat_producing_resistor
%linear resistor
%Follows the relation U=I*R [V]
%Includes the heat produced in the resistor dQ/dt =u(t)*i(t) [J/s = W]
%R is assumed to be constant
nodes
p = foundation.electrical.electrical; % +:left
n = foundation.electrical.electrical; % -:right
dQ = foundation.electical.electrical; % Q:right
end
variables
i = {0, 'A' }; %Current (through)
u = {0, 'V' }; %Voltage (across)
dQ = {0, 'W' }; %Heatflow (across)
end
parameters
R = {1, 'Ohm' }; %resistance
end
branches
i : p.i -> n.i;
end
equations
assert(R>0)
v == p.v - n.v;
v == i*R;
dQ == i*v;
end
end
0 Kommentare
Antworten (1)
Pramil
am 19 Sep. 2024
Bearbeitet: Pramil
am 20 Sep. 2024
Hello Maarten,
The error you are getting is expected as “dQ” is a node and not a variable. If you try and assign a value to a node, the complier thinks you are redefining the class and hence the error.
Now, onto the main issue, how to create a resistor which produces heat in Simscape.
As you want to measure heat, use “dQ = foundation.thermal.thermal” instead of “dQ = foundation.electrical.electrical”. The reason for this is if you refer the following documentations:
You can see that; you can define heat flow “Q” in thermal domain not electrical domain.
To output heat flow through node “dQ”, define a variable “Q” and in “branches” declare that “Q” is of type “dQ.Q” such that it defines heat flow from the component to outside of component.
Finally, equate “Q == i*v” in “equations” for getting the output heat flow. This should create the required block.
Here is the updated code for your reference:
component heat_producing_resistor
%linear resistor
%Follows the relation U=I*R [V]
%Includes the heat produced in the resistor dQ/dt =u(t)*i(t) [J/s = W]
%R is assumed to be constant
nodes
p = foundation.electrical.electrical; % +:left
n = foundation.electrical.electrical; % -:right
dQ = foundation.thermal.thermal; % Q:right
end
variables
i = {0, 'A' }; %Current (through)
v = {0, 'V' }; %Voltage (across)
Q = {0, 'J/s'};
end
parameters
R = {1, 'Ohm' }; %resistance
end
branches
i : p.i -> n.i;
Q : dQ.Q -> *;
end
equations
assert(R>0)
v == p.v - n.v;
v == i*R;
Q == i*v; % Heat flow
end
end
Hope it helps.
0 Kommentare
Siehe auch
Kategorien
Mehr zu Run-Time Parameters finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!