- Index
- » Users
- » Pliskin
- » Profile
Posts
Posts
Hello Everyone,
I don't understand why the following model is not equalt in variables and equation. I do get which the equations and variables are. I just don't understand how I should change the model to get equal size of equations and variables.
type VolumeFlowRate = Real(final quantity = "VolumeFlowRate", final unit = "m3/s");
connector AirFlow "Airflow connector"
flow VolumeFlowRate Q_air;
end AirFlow;
model blower
parameter VolumeFlowRate Q_max = 20000
parameter VolumeFlowRate Q_min = 0.0
Real H;
Interfaces.AirFlow AirOut;
Modelica.Blocks.Interfaces.RealInput u;
equation
H = 0.5 * ((-Q_min) + Q_max) + u * 0.5 * ((-Q_min) + Q_max) + Q_min;
AirOut.Q_air = -(if H > Q_max then Q_max else if H < Q_min then Q_min else H);
end blower;
It tells me 2 variables and 3 equations and therefor structurally singular.
Hey there,
I was actually not missing the equation for .So. it was in the Model I send to you. I thin the equation Out.Q + In.Q = 0; might have been a problem. I deleted it from the SimplePump Model and now it seems to add up.
I did not really understand what you meant by your last post.
sjoelund.se wrote:
Or actually (because you should not connect two connectors that are both in the same model):
SimplePump is a Model I want to use in a bigger model. therefor it needs two connectors.
This is what I did now:
ConnInModif and ConnOutModif are the same as before
model SimplePump "modified pump"
import ConnInModif;
import ConnOutModif;
parameter Modelica.SIunits.VolumeFlowRate Q_min = 1.0 "minimum pump capacity";
parameter Modelica.SIunits.VolumeFlowRate Q_max = 10.0 "maximum pump capacity";
Real H(start = 1.0);
ConnInModif In;
ConnOutModif Out;
Modelica.Blocks.Interfaces.RealInput u = 1;
equation
H = 0.5 * ((-Q_min) + Q_max) + u * 0.5 * ((-Q_min) + Q_max) + Q_min;
Out.Q = -(if H > Q_max then Q_max else if H < Q_min then Q_min else H);
Out.So = In.So;
end SimplePump;
model Test
SimplePump Pumpe;
EffluentSinkModif Sink;
FlowSourceModif Source;
equation
connect(Pumpe.In,Source.Out);
connect(Pumpe.Out,Sink.In);
end Test;
model FlowSourceModif
import ConnOutModif;
ConnOutModif Out;
Modelica.Blocks.Interfaces.RealInput u = 3;
Modelica.Blocks.Interfaces.RealInput w = 4;
equation
Out.Q = u;
Out.So = w;
end FlowSourceModif;
model EffluentSinkModif
import ConnInModif;
ConnInModif In;
end EffluentSinkModif;
Sorry. It is the same as the other connector.
Thanks I will read it. But maybe you can answer me this. It would really help me big time! Why is the following Model structurally singular? Which equation is to much?
connector ConnOutModif
flow Modelica.SIunits.VolumeFlowRate Q;
Modelica.SIunits.MassConcentration So;
annotation(Icon(coordinateSystem(extent = {{-100,-100},{100,100}}, preserveAspectRatio = true, initialScale = 0.1, grid = {2,2})), Diagram(coordinateSystem(extent = {{-100,-100},{100,100}}, preserveAspectRatio = true, initialScale = 0.1, grid = {2,2})));
end ConnOutModif;
model SimplePump "modified pump"
import ConnInModif;
import ConnOutModif;
parameter Modelica.SIunits.VolumeFlowRate Q_min = 1.0 "minimum pump capacity";
parameter Modelica.SIunits.VolumeFlowRate Q_max = 10.0 "maximum pump capacity";
Real H(start = 1.0);
ConnInModif In;
ConnOutModif Out;
Modelica.Blocks.Interfaces.RealInput u;
equation
H = 0.5 * ((-Q_min) + Q_max) + u * 0.5 * ((-Q_min) + Q_max) + Q_min;
Out.Q = -(if H > Q_max then Q_max else if H < Q_min then Q_min else H);
Out.So = In.So;
Out.Q + In.Q = 0;
end SimplePump;
It would be really nice if there was a description on how variables and equations are counted and when variables are left out. But i guess there is no such thing right?!
No i can not build it. It tells me to many equations and counts 4 equations and three variables.
Thanks for the fast reply!
Maybe you can help me with the next one. It's the same Problem. Only that there are counted 16 variables but I only see 15 variables
model SimpleWWInOut
import WWSourceModif;
WWSourceModif WWSo;
Modelica.Blocks.Sources.CombiTimeTable CombiTimeTable1(tableOnFile = true, tableName = "drysimnord", fileName = "drysimnord.txt", columns = {2,3});
SimplePump SimplePump1;
EffluentSinkModif WWSi;
Modelica.Blocks.Sources.Constant const1;
equation
connect(const1.y,SimplePump1.u);
connect(CombiTimeTable1.y,WWSo.data);
connect(WWSo.Out,SimplePump1.In);
connect(SimplePump1.Out,WWSi.In);
annotation(Icon(coordinateSystem(extent = {{-100,-100},{100,100}}, preserveAspectRatio = true, initialScale = 0.1, grid = {2,2})), Diagram(coordinateSystem(extent = {{-100,-100},{100,100}}, preserveAspectRatio = true, initialScale = 0.1, grid = {2,2})));
end SimpleWWInOut;
check gives 17 equations, 16 variables.
variables i am counting(15):
Real WWSo.Out.Q
Real WWSo.Out.So
input Real WWSo.data[1]
input Real WWSo.data[2]
output Real CombiTimeTable1.y[1]
output Real CombiTimeTable1.y[2]
Real SimplePump1.H(start = 1.0)
Real SimplePump1.In.Q
Real SimplePump1.In.So
Real SimplePump1.Out.Q
Real SimplePump1.Out.So
input Real SimplePump1.u;
Real WWSi.In.Q
Real WWSi.In.So
output Real const1.y
Instantiating brings:
class SimpleWWInOut
Real WWSo.Out.Q(quantity = "VolumeFlowRate", unit = "m3/s");
Real WWSo.Out.So(quantity = "MassConcentration", unit = "kg/m3");
input Real WWSo.data[1];
input Real WWSo.data[2];
parameter Boolean CombiTimeTable1.tableOnFile = true "= true, if table is defined on file or in function usertab";
parameter String CombiTimeTable1.tableName = "drysimnord" "Table name on file or in function usertab (see docu)";
parameter String CombiTimeTable1.fileName = "drysimnord.txt" "File where matrix is stored";
parameter Boolean CombiTimeTable1.verboseRead = true "= true, if info message that file is loading is to be printed";
parameter enumeration(LinearSegments, ContinuousDerivative, ConstantSegments) CombiTimeTable1.smoothness = Modelica.Blocks.Types.Smoothness.LinearSegments "Smoothness of table interpolation";
parameter enumeration(HoldLastPoint, LastTwoPoints, Periodic, NoExtrapolation) CombiTimeTable1.extrapolation = Modelica.Blocks.Types.Extrapolation.LastTwoPoints "Extrapolation of data outside the definition range";
parameter Real CombiTimeTable1.offset[1] = 0.0 "Offsets of output signals";
parameter Real CombiTimeTable1.startTime(quantity = "Time", unit = "s") = 0.0 "Output = offset for time < startTime";
final parameter Real CombiTimeTable1.t_min(quantity = "Time", unit = "s", fixed = false) "Minimum abscissa value defined in table";
final parameter Real CombiTimeTable1.t_max(quantity = "Time", unit = "s", fixed = false) "Maximum abscissa value defined in table";
protected discrete Real CombiTimeTable1.nextTimeEvent(quantity = "Time", unit = "s", start = 0.0, fixed = true) "Next time event instant";
protected parameter Real CombiTimeTable1.tableOnFileRead(fixed = false) "= 1, if table was successfully read from file";
parameter Integer CombiTimeTable1.columns[1] = 2 "Columns of table to be interpolated";
parameter Integer CombiTimeTable1.columns[2] = 3 "Columns of table to be interpolated";
parameter Integer CombiTimeTable1.nout(min = 1) = 2 "Number of outputs";
protected Modelica.Blocks.Types.ExternalCombiTimeTable ExternalObject CombiTimeTable1.tableID = Modelica.Blocks.Types.ExternalCombiTimeTable.constructor("drysimnord", "drysimnord.txt", {{}}, 0.0, {2, 3}, Modelica.Blocks.Types.Smoothness.LinearSegments, Modelica.Blocks.Types.Extrapolation.LastTwoPoints) "External table object";
output Real CombiTimeTable1.y[1] "Connector of Real output signals";
output Real CombiTimeTable1.y[2] "Connector of Real output signals"
protected final parameter Real CombiTimeTable1.p_offset[1] = CombiTimeTable1.offset[1] "Offsets of output signals";
protected final parameter Real CombiTimeTable1.p_offset[2] = CombiTimeTable1.offset[1] "Offsets of output signals";
parameter Real SimplePump1.Q_min(quantity = "VolumeFlowRate", unit = "m3/s") = 1.0 "minimum pump capacity";
parameter Real SimplePump1.Q_max(quantity = "VolumeFlowRate", unit = "m3/s") = 10.0 "maximum pump capacity";
Real SimplePump1.H(start = 1.0);
Real SimplePump1.In.Q(quantity = "VolumeFlowRate", unit = "m3/s");
Real SimplePump1.In.So(quantity = "MassConcentration", unit = "kg/m3");
Real SimplePump1.Out.Q(quantity = "VolumeFlowRate", unit = "m3/s");
Real SimplePump1.Out.So(quantity = "MassConcentration", unit = "kg/m3");
input Real SimplePump1.u;
Real WWSi.In.Q(quantity = "VolumeFlowRate", unit = "m3/s");
Real WWSi.In.So(quantity = "MassConcentration", unit = "kg/m3");
output Real const1.y "Connector of Real output signal"
parameter Real const1.k(start = 1.0) "Constant output value";
initial algorithm
if CombiTimeTable1.tableOnFile then
CombiTimeTable1.tableOnFileRead := Modelica.Blocks.Sources.CombiTimeTable.readTableData(CombiTimeTable1.tableID, false, CombiTimeTable1.verboseRead);
else
CombiTimeTable1.tableOnFileRead := 1.0;
end if;
CombiTimeTable1.t_min := Modelica.Blocks.Sources.CombiTimeTable.getTableTimeTmin(CombiTimeTable1.tableID, CombiTimeTable1.tableOnFileRead);
CombiTimeTable1.t_max := Modelica.Blocks.Sources.CombiTimeTable.getTableTimeTmax(CombiTimeTable1.tableID, CombiTimeTable1.tableOnFileRead);
equation
WWSo.Out.Q = -WWSo.data[1];
WWSo.Out.So = WWSo.data[2];
assert(CombiTimeTable1.tableName <> "NoName","tableOnFile = true and no table name given");
when {time >= pre(CombiTimeTable1.nextTimeEvent), initial()} then
CombiTimeTable1.nextTimeEvent = Modelica.Blocks.Sources.CombiTimeTable.getNextTimeEvent(CombiTimeTable1.tableID, time, CombiTimeTable1.tableOnFileRead);
end when;
CombiTimeTable1.y[1] = CombiTimeTable1.p_offset[1] + Modelica.Blocks.Sources.CombiTimeTable.getTableValue(CombiTimeTable1.tableID, 1, time, CombiTimeTable1.nextTimeEvent, pre(CombiTimeTable1.nextTimeEvent), CombiTimeTable1.tableOnFileRead);
CombiTimeTable1.y[2] = CombiTimeTable1.p_offset[2] + Modelica.Blocks.Sources.CombiTimeTable.getTableValue(CombiTimeTable1.tableID, 2, time, CombiTimeTable1.nextTimeEvent, pre(CombiTimeTable1.nextTimeEvent), CombiTimeTable1.tableOnFileRead);
SimplePump1.H = 0.5 * (SimplePump1.Q_max - SimplePump1.Q_min) * (1.0 + SimplePump1.u) + SimplePump1.Q_min;
SimplePump1.Out.Q = -(if SimplePump1.H > SimplePump1.Q_max then SimplePump1.Q_max else if SimplePump1.H < SimplePump1.Q_min then SimplePump1.Q_min else SimplePump1.H);
SimplePump1.Out.So = SimplePump1.In.So;
SimplePump1.Out.Q + SimplePump1.In.Q = 0.0;
const1.y = const1.k;
WWSo.Out.Q + SimplePump1.In.Q = 0.0;
SimplePump1.Out.Q + WWSi.In.Q = 0.0;
SimplePump1.u = const1.y;
CombiTimeTable1.y[1] = WWSo.data[1];
CombiTimeTable1.y[2] = WWSo.data[2];
SimplePump1.In.So = WWSo.Out.So;
SimplePump1.Out.So = WWSi.In.So;
end SimpleWWInOut;
Regards,
Pliskin
Hello everyone,
I have a problem to level up my equations and variables or better a problem to identify what is counted by open modelica as a variable and what as an equation.
This is a small Model I created:
model ConstanteTest
Modelica.Blocks.Interfaces.RealInput u = 2;
Durchreiche durch;
EffluentSinkModif Sink;
FlowSourceModif Source;
equation
durch.u = u;
connect(Source.Out,durch.In);
connect(Sink.In,durch.Out)
annotation(Icon(coordinateSystem(extent = {{-100,-100},{100,100}}, preserveAspectRatio = true, initialScale = 0.1, grid = {2,2})), Diagram(coordinateSystem(extent = {{-100,-100},{100,100}}, preserveAspectRatio = true, initialScale = 0.1, grid = {2,2})));
end ConstanteTest;
When I check the Model OMedit tells me the model has 11 equations and 11 variables. So far so good. When I Initiate the model I get the following message.
class ConstanteTest
input Real u = 2.0;
Real durch.In.Q(quantity = "VolumeFlowRate", unit = "m3/s");
Real durch.In.So(quantity = "MassConcentration", unit = "kg/m3");
Real durch.Out.Q(quantity = "VolumeFlowRate", unit = "m3/s");
Real durch.Out.So(quantity = "MassConcentration", unit = "kg/m3");
input Real durch.u;
Real Sink.In.Q(quantity = "VolumeFlowRate", unit = "m3/s");
Real Sink.In.So(quantity = "MassConcentration", unit = "kg/m3");
Real Source.Out.Q(quantity = "VolumeFlowRate", unit = "m3/s");
Real Source.Out.So(quantity = "MassConcentration", unit = "kg/m3");
input Real Source.u;
input Real Source.w = 4.0;
equation
durch.Out.Q = durch.In.Q * durch.u;
durch.Out.So = durch.In.So;
durch.Out.Q + durch.In.Q = 0.0;
Source.Out.Q = Source.u;
Source.Out.So = Source.w;
durch.u = u;
durch.In.Q + Source.Out.Q = 0.0;
durch.Out.Q + Sink.In.Q = 0.0;
Source.Out.So = durch.In.So;
Sink.In.So = durch.Out.So;
end ConstanteTest;
As far as I see it there are 12 variables and 10 equations. So my question is how does OMedit count the variables and equations? Is there a formula for it or an algorithm to know maybe why some variables/equations are not counted?
Regards,
Pliskin
Could you tell me what useStart="false" means? I changed the variables to fixed=true but it still seems not to be working. Maybe I am missing something out here.
Here is an Example of a variable from the Model_init.xml file:
<ScalarVariable
name = "Settler.hs"
valueReference = "1001"
description = "height of sludge layer"
variability = "continuous" isDiscrete = "false"
causality = "internal" isValueChangeable = "true"
alias = "noAlias"
classIndex = "1" classType = "rSta"
isProtected = "false"
fileName = "C:\OpenModelica1.9.1Nightly\lib\omlibrary\WasteWater.mo" startLine = "1671" startColumn = "11" endLine = "1671" endColumn = "48" fileWritable = "true">
<Real useStart="false" fixed="false" useNominal="false" unit="m" displayUnit="m" />
</ScalarVariable>
alias = "noAlias"
classIndex = "52" classType = "rDer"
isProtected = "false"
fileName = "C:\OpenModelica1.9.1Nightly\lib\omlibrary\WasteWater.mo" startLine = "783" startColumn = "9" endLine = "783" endColumn = "82" fileWritable = "true">
<Real useStart="false" fixed="true" useNominal="false" min="0.0" unit="mg/l" displayUnit="mg/l" />
And is there a way to see if "system("WasteWater.ASM1.Examples.SmallPlant.exe -overrideFile small_asm1.txt");" is working proberly because I don't get any message at all after using it.
Yes I know that override does not make them constants. Thanks I will try it!
So you are saying the 54 variables which have the startvalue 0.0 while building the model need to be set and no other variables?! -That is what i was trying.
"If you want to set a particular start-value, you need to set fixed=true. "
So if I set all the 54 variables in my model to fixed = true I can change them using the setInitStartXml oder override function? But doesn't that make them to constants?
Thanks already for your fast reply!
Hi,
I am trying to set my initial start values using a .txt or .mos-file because it is a big model with many variables. I found this threat https://www.openmodelica.org/index.php/ … pic?id=715 where they seem to have found a solution but the way they do it won't work.
I was using OMShell and these functions
buildModel(WasteWater.ASM1.Examples.SmallPlant);
setInitXmlStartValue("WasteWater.ASM1.Examples.SmallPlant_init.xml", InitialComponents, InitialValues, "WasteWater.ASM1.Examples.SmallPlant_init.xml");
system("WasteWater.ASM1.Examples.ComplexPlant.exe");
Instead of InitialComponents and Initial Values i also tried to use specific variables and instead of system() i also tried simulate().
I also tried
buildModel(WasteWater.ASM1.Examples.SmallPlant);
system("WasteWater.ASM1.Examples.SmallPlant.exe -overrideFile small_asm1.txt");
But I always geht the same message: "Warning: Assuming fixed start value for the following 54 variables"
I had a look into the file_init.xml file and noticed something for each variable that said "useStart = false" so i was wondering if that is causing the problem since for the fixed variables it says "useStart = true".
Maybe something else is wrong. I hope you can help.
Regards
Pliskin
Hey Ben!
I do have the same Problem. Have you been able to solve it and add inital values for your variables using the .mos file?
If so could you tell me how?
Greetings
Pliskin
Hello!
I am trying to run a script before starting the simulation, so i used at the beginning of my model
function runScript "Runs the mos-script specified by the filename."
input String filename ;
output String result;
external "builtin" ;
annotation(preferredView = "text");
end runScript;
now my question is: Where do you decline the path of the file i wanna read? or does the OMEdit automatically look in the direction where my main package is saved?
Hey there!
It was actually a mistake in the programm. the redeclare for the O2 Sensor was not necessary so we just removed it and now the error i got is gone. and fyi the wastewaterlibrary i am using is already written on 3.2
I am looking in to it. Do you have something like a step by step manual for the savetotalscode? I haven't done it before but i am trying to find out which librarie i am using. It is definetly a newer version, you are right about that.
class test
import WW;
extends Modelica.Icons.Example;
.
.
.
WW.ASM1.sensor_O2 sensor_O2(So(redeclare type SignalType = Real));
.
.
.
equation
.
.
.
end test;
model sensor_O2
extends WW.Icons.sensor_O2;
Interfaces.WWFlowAsm1in In;
Modelica.Blocks.Interfaces.RealOutput So;
equation
In.Q = 0;
So = In.So;
end sensor_O2;
Does this help? It`s a complex model, so i tried to write the important lines down.
Thanks for the fast answer.
Hello community,
I need help with understanding some error messages.
First of all i would like to ask if there is a trick or a special way how to find out what the error message is trying to tell you. Because I find it quite difficult to figure out what the actual error is.
Secondly i would like to ask you guys if you could give me a hint what this error is about:
Error: Variable X.So: In modifier SignalType(redeclare CLASS(SignalType, partial = false, encapsulated = false, prefixes: public redeclare , type, DERIVED(.Real,))
), not processed in the built-in class Real.
Greetings
Pliskin
Thanks for the Help!
At least that Problem ist gone. More to come!
for example when i write:
partial model WasteWater.ASM1.Interfaces.ASM1base
"Base class of WWTP modelling by ASM1"
extends Interfaces.stoichiometry;
package WWU = WasteWater.WasteWaterUnits;
// parameters based on the original ASM1 publication based on 15 deg C
Real mu_h "Maximum heterotrophic growth rate f(T) [day^-1]";
Real b_h "Heterotrophic decay rate f(T) [day^-1]";
Real mu_a "Maximum autotrophic growth rate f(T) [day^-1]";
//Real K_nh "Half-saturation (auto. growth) f(T) [g NH-N/m3]";
Real b_a "Autotrophic decay rate f(T) [day^-1]";
Real k_a "Ammonification rate f(T) [m3/(g COD day)]";
Real k_h "Maximum specific hydrolysis rate f(T) [g Xs/(g Xbh COD day)]";
Real K_x "Half-saturation (hydrolysis) f(T) [g Xs/(g Xbh COD)]";
parameter Real mu_h_T=4.0
"Maximum heterotrophic growth rate at T=15 deg C [day^-1]";
parameter Real b_h_T=0.28 "Heterotrophic decay rate at T=15 deg C [day^-1]";
parameter Real mu_a_T=0.5
"Maximum autotrophic growth rate at T=15 deg C[day^-1]";
parameter Real b_a_T=0.1 "Autotrophic decay rate at T=15 deg C [day^-1]";
parameter Real k_a_T=0.06
"Ammonification rate at T=15 deg C [m3/(g COD day)]";
parameter Real k_h_T=1.75
"Maximum specific hydrolysis rate at T=15 deg C [g Xs/(g Xbh COD day)]";
parameter Real K_x_T=0.0175
.
.
.
.
// Outputs
Out.Q + In.Q = 0;
Out.Si = Si;
Out.Ss = Ss;
Out.Xi = Xi;
Out.Xs = Xs;
Out.Xbh = Xbh;
Out.Xba = Xba;
Out.Xp = Xp;
Out.So = So;
Out.Sno = Sno;
Out.Snh = Snh;
Out.Snd = Snd;
Out.Xnd = Xnd;
Out.Salk = Salk;
MeasurePort.Si = Si;
MeasurePort.Ss = Ss;
MeasurePort.Xi = Xi;
MeasurePort.Xs = Xs;
MeasurePort.Xbh = Xbh;
MeasurePort.Xba = Xba;
MeasurePort.Xp = Xp;
MeasurePort.So = So;
MeasurePort.Sno = Sno;
MeasurePort.Snh = Snh;
MeasurePort.Snd = Snd;
MeasurePort.Xnd = Xnd;
MeasurePort.Salk = Salk;
end ASM1base;
and I check it. It will say :
Syntax 14:30:47 32:3-33:2 No viable alternative near token: Base class of WWTP modelling by ASM1
Hello Community,
This is my first post here. I am a student and am trying to get the Modelica WasteWater Library working for Openmodelica.
My Problem: Everytime when I am useing a partial model or partial block and try to ckeck the model it gives an Error saying "No viable alternativ near token:"
So is there something you need to add to the partial model that you did not need with dymola?
Thanks
Pliskin
- Index
- » Users
- » Pliskin
- » Profile