- Index
- » Users
- » mmostell
- » Profile
Posts
Posts
Thanks for the response @sjoelund !
Technically, what is the difference between an if-statement and an if-equation? And if the issue is that there is 1 equation in the first if statement and 2 equations in the else statement, how would you suggest working around this problem?
Again, thanks for the help!
Hi,
I am having a problem using an if-statement in a model I am developing to simulate bacteria growth in microfluidic systems.
While I have used if-else statements in Modelica before (actually in other sub-models for this system), I am encountering simulation failures for a current model that I am attempting to develop.
The model code is as follows:
model GrowthVelocity
BiofilmNode i,o,p;
parameter Real dz = 1;
parameter Real biofilm_density = 1;
Real Number;
Real biomass_production;
Real inactivebiomass_prod;
equation
if Number > 1 then
i.uz = (( (2*dz) * (biomass_production + inactivebiomass_prod)) / biofilm_density) + p.uz;
else
o.uz = 0;
i.uz = (( (2*dz) * (biomass_production + inactivebiomass_prod)) / biofilm_density) + p.uz;
end if ;
end GrowthVelocity;
When I attempt to run the simulation, I get the following error:
Error: The language feature if-equations is not supported. Suggested workaround: rewrite equations using if-expressions: equation
if thebiofilm.velocity_char[1].Number > 1.0 then
thebiofilm.velocity_char[1].i.uz = 2.0 * (thebiofilm.velocity_char[1].dz * (thebiofilm.velocity_char[1].biomass_production + thebiofilm.velocity_char[1].inactivebiomass_prod) / thebiofilm.velocity_char[1].biofilm_density) + thebiofilm.velocity_char[1].p.uz;
else
thebiofilm.velocity_char[1].o.uz = 0.0;
thebiofilm.velocity_char[1].i.uz = 2.0 * (thebiofilm.velocity_char[1].dz * (thebiofilm.velocity_char[1].biomass_production + thebiofilm.velocity_char[1].inactivebiomass_prod) / thebiofilm.velocity_char[1].biofilm_density) + thebiofilm.velocity_char[1].p.uz;
end if;
I am confused because it is essentially telling me that I am using the wrong if-statement syntax, and then suggests the exact same syntax as a way to fix the error. Again, I have used this exact same construct before in a similar model such as the following with no problems:
model ActiveBiomass "a characteristic :: similar to biomass model"
BiofilmNode i,o,p;
parameter Real dz = 1;
parameter Real Voxygen = 1;
parameter Real Yboxygen = 1;
parameter Real Beta = 1;
parameter Real Koxygen = 1;
parameter Real B = 1;
Real Number;
Real biomass_production;
equation
biomass_production = B*o.rho_biomass*(o.rho_oxygen / (Koxygen+o.rho_oxygen));
if Number > 1 then
der(o.rho_biomass) = biomass_production - (o.uz * ((i.rho_biomass - p.rho_biomass) / (2*dz))) - (o.rho_biomass * ((i.uz - p.uz) / (2*dz)));
else
o.rho_biomass = 0;
end if;
end ActiveBiomass;
I do not see why one model would work with this syntax and another would not, even though they are identical in structure. Has anyone else encountered a similar problem or have any insight as to why this would not be working?
Any help would be greatly appreciated.
Matt
I am attempting to build a model first to prove the usage of the pder operator in modelica to perform partial derivatives, and am looking for help in implementing this function and seeing if it actually works as stated.
Since the text by Paul Fritzon is a few years old and discusses the use of Modelica 2.1, it is difficult to figure out from the literature what functions are actually available at this time to perform these PDEs. There are a number of papers that discuss "methods" of dealing with partial differential equations in modelica, but for realistic purposes, I am curious to see what exactly is needed in order to perform these types of analysis. Such PDEs seem like they should be computable in OM since they show up in a number of situations and are needed for most real-world physical phenomena.
The sample model given by the Fritzon book is as below for 1-dimensional heat flow in a conducting rod:
model HeatLine1D
import DifferentialOperators1D.pder;
parameter DomainLine1DGrid rod;
FieldLine1DGrid u (domain = rod, FieldValueType=SI.Temperature);
equation
der(u) = pder(u, D.x2) in rod.interior;
u = 20*sin(PI*time/12)+300 in rod.left;
pder(u, D.x) = 0 in rod.right;
end HeatLine1D;
Any help in this area is extremely helpful and would be of great value to many.
Thanks and I look forward to any input you can provide.
Hi all,
I'm still relatively new to openmodelica and have been finding ways around this problem for some time, but its finally come to a head and I need to figure it out.
Whenever I try to use any modelica standard library elements (i.e. SIunits, Math functions, etc.) i have an error message when I attempt to run the simulation.
For example:
model nonlinearpendulum
Real theta;
Real omega;
parameter Real L=2;
constant Real g=Modelica.Constants.g_n;
equation
der(theta) = omega;
der(omega) = -(g/L)*Modelica.Math.sin(theta);
end nonlinearpendulum;
simulate(nonlinearpendulum, starTime = 0, stopTime = 10)
record SimulationResult
resultFile = "Simulation failed.
Error: Variable Modelica.Constants.g_n not found in scope nonlinearpendulum
Error: Error occured while flattening model nonlinearpendulum
"
end SimulationResult;
I've tried extending the call to go to a higher level i.e. ModelicaLibrary.Modelica.Math.sin, but it still fails with the same message.
Any ideas on what I need to do to fix this so I can use these elements?
Thanks!
Hi
I am new to Open Modelica and am currently trying to install and run it on my Macbook Pro. It said I needed to upgrade to Snow Leopard so I did all that and obtained all the other stuff that open modelica supposedly needed (i.e. xcode, etc.).
However, whenever i try to open the shell for OM, it creates the error "bad CPU type in executable." Otherwise when i try to open the OMShell app it comes up with an error "You can't open the application OMShell because it is not supported on this type of Mac.
Any ideas why this is and how to fix it? I have installed all of the necessary software, etc., that it supposedly needs. But i believe that my mac (intel based, originally running tiger OS), is 32 bit, and maybe it needs to use 64? Seems silly to me given the extreme amount of limited back-compatibility that offers but I cant think of what else it could be.
Thanks in advance.
- Index
- » Users
- » mmostell
- » Profile