Allow me to write at the top, for the following problem, I get the following method, but I don't know if it works. Is it possible to change the Real variable to the parameter Real variable in the modelica language, or through a method like a connector?
model A
parameter Real T=T1;
Real T1=300;
equation
end A;
I want to connect the model that I built with the thermal power library to the code that I wrote myself, as shown below (only the key code is shown for confidentiality reasons).
ThermalPower.TwoPhase.SourcesAndSinks.FlowBoundary_T flowBoundary_T(
redeclare package Medium = WaterMedium,
m_flow0=11,
T0=t.T)
annotation (Placement(transformation(extent={{516,410},{496,430}})));
ex t;
equation
connect(flowBoundary_T.port, multiData19.port_a)
model ex
Real T;
equation
T=300;
end ex;
But unfortunately the following error will occur.
When I simply change the temperature to the following constant, it works
ThermalPower.TwoPhase.SourcesAndSinks.FlowBoundary_T flowBoundary_T(
redeclare package Medium = WaterMedium,
m_flow0=11,
T0=300)
annotation (Placement(transformation(extent={{516,410},{496,430}})));
I do not know why, I want to know if there is an easy way to connect the model.If this simple substitution doesn't work, how do I create a connector to connect the two models? Thank you in advance for your response!
By the way, does anyone know the fluid port interface in the thermalpower library, why does it default to 0 for a given flow rate, I want to operate it given a flow rate, thank you for your reply
model A
ThermalPower.TwoPhase.Interfaces.FlowPort flowPort
annotation (Placement(transformation(extent={{-4,-2},{16,18}})));
equation
flowPort.h_outflow=1e6;
flowPort.m_flow=150;
annotation (uses(ThermalPower(version="1.26"), Modelica(version="4.0.0")));
end A;
That is not related to the connector but to the variability in the model ex
.
The T0
is declared to be a parameter (I believe) and now you are using a continuous-time variable ex.T
It should be possible to change it to:
model ex
parameter Real T=300;
end ex;
If you for reason want to give it as an equation you could do:
model ex
parameter Real T(fixed=false);
initial equation
T=300;
end ex;
One reason for this strictness is that equations can be written in a simpler form if some variables are parameters and don't change during the simulation.