Archived OpenModelica forums. Posting is disabled.

Alternative forums include GitHub discussions or StackOverflow (make sure to read the Stack Overflow rules; you need to have well-formed questions)


Forgot password? | Forgot username? | Register
  • Index
  • » Users
  • » Pyrukar
  • » Profile

Posts

Posts

Feb-28-21 18:20:16
Category: Programming

Hi, i tried to use the Modelica.Media.Air.MoistAir.h_pTX function but i dont get the values i should get. i tried to reproduce some easys to check values and the result was off by a factor of about 2 to the values i get from the moist Air diagramm. does someone know more about this function that can be found in the documentation?

maybe i interprete the wrong values current/smile can someone please help me?

Feb-24-21 10:48:16
Category: Programming
Feb-24-21 01:06:44
Category: Programming

Hi, third topic in the last few days ... but at this point my project is nearly finished and my understanding of modelica is getting better and better.

i got as far as simulating but one boolean variable doesnt behave as it should and i cant find the error.

unfortunatly the attatchments in this forum seem to be broken so i cant provide you a immage of the Plot.

What i can say that the Booliean condition is B = A<18 ; and a is >18 nearly all the time but B gets true on the first time A gets smaller than 18 and stays true besides A getting bigger than 18 again. can someone explain why this behavoir can happen and how to fix it?
replacing the condition with a small if condition doesnt help at all.

Feb-23-21 23:57:16
Category: Programming

in the mean time im one step further:

i now know that the simulation fails at a state and therefore the plot ends at that point.

the reason why it breaks is probably a If condition (x>y) makes trouble because x is nearly similar to y but i dont realy get why its a problem. x and y are Reals and the difference is already at the third decimal. This shouldnt give a identity and even a x>=y doesnt change anything current/sad what is the Problem there?

EDIT: Solved the Problem myself and it didnt have anything to do with the if condition but with some typo in the conditioned part current/smile

Feb-23-21 21:25:00
Category: Programming

Okay now i updatet the whole Model to MSL 4.0.0 and still got problems:

If i use a model which contains only the model CombiTimeTable it works perfectly fine but if i integrate it to the complete model and use the y[:] to get the values only about 2000 of the 8760 Values are importet from my file. How could this happen and how to debug this?

Feb-23-21 14:33:15
Category: Programming

Okay two more Problems to be solved:

1. My Model is still on version 3.2.3 and doesnt like to import a Model of version 4.0.0. This results in this warning and no integration done:
"Package Name" requested package Modelica of version 3.2.3. Modelica 4.0.0 is used instead which states that it is only compatible with a conversion script. OpenModelica currently does not support conversion scripts and will proceed with potential issues as a result.
how can i Fix that one without rewriting this?

2. I didnt get the OMshell comandline to work as i assumed so i until now worked with unloading the original Modelica Library and loading the new (loaded from github) 4.0.0. Master manually. but these steps need to be redone after each start of the OMedit. can someone please tell me how to automate this?

EDIT: Third question popping up right now ... i wanted to go around the questions 1 and 2 by using the standard Modelica Library and the txt format. There i get the error (wile compiling for simulation): The file name for a table (= "correctPath") is defined, but not the corresponding table name.

if i fill the parameter tableName with the matching stated name in the .txt it gives the same Error current/sad

Feb-23-21 10:30:30
Category: Programming

okay i now imported the new Modelica Master and found the Combi time Table and tried to feed it with values ... but i got an error message while compiling (simulating) : Error in line 11 when reading numeric data of matrix "Value(8760,3)" from file: ...

im aware that this is the last Value in the csv file (8670 lines and three colums if interpretet with excel) but i dont know where the Problem is.


EDIT: solved that mystery myself: i had german formating in place means , for decimal separation and ; for column separation ... needed . for decimal and , for column separation current/smile hint: csv = comma seperated values not semicolon separated values current/smile

Feb-23-21 07:55:48
Category: Programming

Okay if i pretend my time steps are in hours i could say every timestep aka second is one hour and the plots can show the right unit (hour) instead of seconds? luckyly i dont have to integrate over time.

Feb-23-21 07:30:20
Category: Programming

Well a new questions:
you seem to use Linux for installing the Master version of the Library ... im on windows ... can you tell me where (probably on github?!) i can find that master library? i Found the the Test Library there but not the master.

and the Old one with the timesteps still isnt answered. Is there a good answer to?

Feb-22-21 09:22:44
Category: Programming

okay, thanks for that,

but shouldnt Modelica.Blocks.Tables.CombiTable1D work? i mean sure i can make a txt ouf of my file and format it in the way that is needed acording to the documentation. But i dont understand the function and its not a example i could simply simulate to test it (Assertion triggered during translation: "tableOnFile = false and parameter table is an empty matrix")

also the Utility section looks promising. But the Modelica.Utilities.Examples.ReadRealMatrixFromFile doesnt run and besides that i dont have a Matlab file current/sad

Could i maybe use the Stream function to read strings from my external data an convert this into Reals ... could that work?

either way im downloading the nightly Build now ... maybe this new, promised function will work for me ( and maybe im able to understand it)

Feb-22-21 07:25:25
Category: Programming

so you are telling me, that csv files are only possible with the latest devbuild?

and can you please link me the documentation where i can look up supported files?

Feb-21-21 22:55:56
Category: Programming

Hi,

i need to import meassurement data into a simulation and i dont realy get to do that. i have a dokument without any filename extention (works fine if added .csv for showing in excel) with  8760(1per hour for a year) data rows.

i found Modelica.Blocks.Tables.CombiTable1D in the examples but cant get it to function ... can anybody please give me some hints or direct me to a tutorial where i can see how it has to be done?

Next question would be, how to get these values in to the Variables at the right time and there comes Question 3: is it possible to run a simulation in timesteps of hours instead of seconds? I mean sure I can run it for 8760s and pretend it should be hours but would be cool if i could tell the Simulation to do hour steps.

Hope someone can help me out current/smile

Feb-19-21 22:51:29
Category: Programming

okay my last question is still not answered but i think i finally understood how medium is meant to be used. Following code does Run but  "RelHumid=  Modelica.Media.Air.MoistAir.relativeHumidity (state1);"  is alsways =1 which it shouldnt be. I checked with hx-diagramm (by hand not modelica) that at 14°C and 1bar pressure the absolute humidity is about 10g (and Modelica gets this value right so it should be true and something is obviously working)
but if i define the mass of water to 1g the Relative humidity shoud be 10% but the equation always says 1 (100%) regardless of any parameters current/smile

Is my understanding of this function wrong or is there a bug with that one?

Code:


model TestModel1


parameter Modelica.SIunits.Temp_C t = 14; 
constant Real p = 1.0e5;
parameter Modelica.SIunits.Mass water=0.001;


Real AbsHumid[2];
Real AbsHumidMax;
Real RelHumid;

Modelica.Media.Air.MoistAir.ThermodynamicState state1;



equation

AbsHumid[1]= 1-water;
AbsHumid[2]=water;

state1.p = p;
state1.T = Modelica.SIunits.Conversions.from_degC(t);
state1.X = AbsHumid;

AbsHumidMax = Modelica.Media.Air.MoistAir.xsaturation(state1);

RelHumid=  Modelica.Media.Air.MoistAir.relativeHumidity (state1);

end TestModel1;

Feb-18-21 21:23:34
Category: Programming

Only the last one was made up by me, the others are straight out of examples or even the ModelicaSpec34.pdf ... why dont they work if i try to redo them in my models?

Feb-18-21 18:48:16
Category: Programming

well than i have to test some more ... a other question that sometimes bothers me is: in many examples (even in the language declaraiton ModelicaSpec34.pdf ) things like follows seem to compile but not if i try current/sad

Code:


import SI= Modelica.SIunits;

SI.Mass x;

or

Code:

  package Medium = Air.MoistAir "Medium model";

with following package definition

Code:

package Medium = Air.MoistAir "Medium model";

As far i can say it at least the Import shoud work but it doesnt current/sad the question is why?

and shouldnt even:

Code:


import Medium = Modelica.Media.Air.MoistAir

Medium.BaseProperties

work?

Feb-18-21 16:30:33
Category: Programming

Okay, Im at the next point where i dont understand, whats wrong with my code:

as in my former posting i declared the ... .BaseProperties medium (...)

then the code compiles and if i type medium. its recognised and i get things like  medium.x_sat as a posibility. But if i type  abc = medium.x_sat

i get the errror Code:Variable medium.x_sat not found in scope TestModel.

How can i work with the MoistAir i defined above?

Feb-18-21 10:49:28
Category: Programming

Okay, that was Easy, Thanks for the explanation current/smile

is it possible that this variable is given to the model via a connector from an

means Connector has parameter Real s=1;

and Model2 has

connector.s y;

Real x(start=y);


or is it important that the parameter definition is within the model itself.
As far as i understand the definition this attribute can be passed through a connector, correct?

Feb-18-21 09:55:21
Category: Programming

i tried to get some tests done but i dont get why folloing code compiles but the code below doesnt anymore. Why does setting variables doesnt Work with .BaseProperties

This compiles:

Code:


model TestModel

Modelica.SIunits.Temp_K t = 294;
Real p = 1.0e5;
Real AbsHumid= 0.01;

Modelica.Media.Air.MoistAir.BaseProperties Medium(
    T(start=294, fixed=false),
    X(start={0.95,0.05}),
    p(start=1.0e5, fixed=false));

equation

end TestModel;

this Doesnt anymore:

Code:


model TestModel


Modelica.SIunits.Temp_K t = 294;
Real p = 1.0e5;
Real AbsHumid= 0.01;

Modelica.Media.Air.MoistAir.BaseProperties Medium(
    T(start= t, fixed=false),
    X(start={0.95,0.05}),
    p(start=1.0e5, fixed=false));

equation

end TestModel;

Error Message:[Test: 21:9-21:17]: Component start of variability parameter has binding 't' of higher variability continuous

neither does this compile:

Code:


model TestModel


Modelica.SIunits.Temp_K t = 294;
Real p = 1.0e5;
Real AbsHumid= 0.01;

Modelica.Media.Air.MoistAir.BaseProperties Medium(
    T(start= 294, fixed=false),
    X(start={0.95,0.05}),
    p(start= p, fixed=false));

equation

end TestModel;

Same Error

Changing variables to Integer gives another error but at last still similar

Can somebody pleas explain, how to get variables into Baseproperties and how to change BaseProperties after setting them initially? If there is any tutorial on that please show me where current/smile

Feb-17-21 10:46:22
Category: Programming

Thanks for your Reply,

maybe you can answer me this question:

What parts of the Ambient declaration (including expands) do you realy need to get a fluid source that gives all the Medium.Air.MoistAir variables? reading some tutorials i get the impression that in the Ambient Thermal declaration there is quite so unnessesary stuff i could just delet. I mean i Get it there is the possibility to use fixed values or imput values which expands the declaration, but whats all the stuff in the expanded class all about. lets say all i Care fore is Temperature and Humidity imputs at a fixed Pressure ... pushing with a imputed massflow through the system, wouldnt that be a rather short declaration or what do i need for shuch a rather limited flowsoruce?

Feb-17-21 09:43:49
Category: Programming

okay thanks for the clarification so i should use fluid if i want to use the predefinded moistair?

since nobody answered i started to change the Connectors and Ambient in the Thermal category like follows in the spoiler:

 Spoiler Show Spoiler Hide Spoiler
 

Code:


connector MoistAir_FlowPort

  Modelica.Media.Air.MoistAir medium ;
  Modelica.SIunits.Pressure p;
  flow Modelica.SIunits.MassFlowRate m_flow;
  Modelica.SIunits.SpecificEnthalpy h;
  flow Modelica.SIunits.EnthalpyFlowRate H_flow;
   
annotation (Documentation(info = "<html>
Basic definition of the connector.<br>
<strong>Variables:</strong>
<ul>
<li>Pressure p</li>
<li>flow MassFlowRate m_flow</li>
<li>Specific Enthalpy h</li>
<li>flow EnthaplyFlowRate H_flow</li>
</ul>
If ports with different media are connected, the simulation is asserted due to the check of parameter.
</html>"),
    Icon(graphics = {Ellipse(fillColor = {85, 170, 127}, fillPattern = FillPattern.Solid,extent = {{-100, 100}, {100, -100}}, endAngle = 360)}));
end MoistAir_FlowPort;

model MoistAir_Ambient "Ambient with constant properties"

  Modelica.Thermal.FluidHeatFlow.Media.Medium medium=Modelica.Thermal.FluidHeatFlow.Media.Medium() "Medium"
    annotation(choicesAllMatching=true);
  parameter Modelica.SIunits.Temperature T0(start=293.15, displayUnit="degC")
    "Initial temperature of medium";
  parameter Boolean T0fixed=false
    "Initial temperature guess value or fixed"
  annotation(choices(checkBox=true));
  output Modelica.SIunits.Temperature T_port "Temperature at flowPort_a";
  output Modelica.SIunits.Temperature T(start=T0, fixed=T0fixed) "Outlet temperature of medium";
  Interfaces.FlowPort_a flowPort(final medium=medium)
    annotation (Placement(transformation(extent={{-110,-10},{-90,10}})));
protected
  constant Boolean Exchange=true "Exchange of medium via flowport"
    annotation(HideResult=true);
  Modelica.SIunits.SpecificEnthalpy h "Specific enthalpy in the volume";
equation
  T_port=flowPort.h/medium.cp;
  T=h/medium.cp;
  // mass flow -> ambient: mixing rule
  // mass flow <- ambient: energy flow defined by ambient's temperature
  if Exchange then
    flowPort.H_flow = semiLinear(flowPort.m_flow,flowPort.h,h);
  else
    h=flowPort.h;
  end if;
annotation (Documentation(info="<html>
<p>
Partial model of single port at the left, defining the medium and the temperature at the port.
</p>
</html>"), Icon(coordinateSystem(preserveAspectRatio=true, extent={{-100,-100},
            {100,100}}), graphics={       Text(
          extent={{-150,140},{150,100}},
          lineColor={0,0,255},
          textString="%name")}));

 
 

  parameter Boolean usePressureInput = false "Enable / disable pressure input" annotation(
    Evaluate = true,
    choices(checkBox = true));
 
  parameter Modelica.SIunits.Pressure constantAmbientPressure(start = 0) "Ambient pressure" annotation(
    Dialog(enable = not usePressureInput));
 
  parameter Boolean useTemperatureInput = false "Enable / disable temperature input" annotation(
    Evaluate = true,
    choices(checkBox = true));

  parameter Boolean useHumidityInput = false "Enable / disable humidity input" annotation(
    Evaluate = true,
    choices(checkBox = true));
 
  parameter Modelica.SIunits.Temperature constantAmbientTemperature(start = 293.15, displayUnit = "degC") "Ambient temperature" annotation(
    Dialog(enable = not useTemperatureInput));
  Modelica.Blocks.Interfaces.RealInput ambientPressure = pAmbient if usePressureInput annotation(
    Placement(transformation(extent = {{-20, -20}, {20, 20}}, rotation = 180, origin = {100, 60}), iconTransformation(extent = {{-20, -20}, {20, 20}}, rotation = 180, origin = {100, 60})));
  Modelica.Blocks.Interfaces.RealInput ambientTemperature = TAmbient if useTemperatureInput annotation(
    Placement(transformation(extent = {{-20, -20}, {20, 20}}, rotation = 180, origin = {100, -60}), iconTransformation(extent = {{-20, -20}, {20, 20}}, rotation = 180, origin = {100, -60})));
  Modelica.Blocks.Interfaces.RealInput ambientHumidity annotation(
    Placement(visible = true, transformation(origin = {100, 0}, extent = {{-20, -20}, {20, 20}}, rotation = 180), iconTransformation(origin = {110, 70}, extent = {{-20, -20}, {20, 20}}, rotation = 180)));
protected
  Modelica.SIunits.Pressure pAmbient;
  Modelica.SIunits.Temperature TAmbient;
equation
  if not usePressureInput then
    pAmbient = constantAmbientPressure;
  end if;
  if not useTemperatureInput then
    TAmbient = constantAmbientTemperature;
  end if;
  MoistAir_FlowPort.p = pAmbient;
  T = TAmbient;
  annotation(
    Documentation(info = "<html>
<p>(Infinite) ambient with constant pressure and temperature.</p>
<p>Thermodynamic equations are defined by Partials.Ambient.</p>
</html>"),
    Icon(coordinateSystem(preserveAspectRatio = true, extent = {{-100, -100}, {100, 100}}), graphics = {Ellipse(lineColor = {255, 0, 0}, fillColor = {0, 0, 255}, fillPattern = FillPattern.Solid, extent = {{-90, 90}, {90, -90}}, endAngle = 360), Text(extent = {{20, 80}, {80, 20}}, textString = "p"), Text(extent = {{20, -20}, {80, -80}}, textString = "T")}));
end MoistAir_Ambient;

the Ambient is not yet finished, but can you please tell me, if the idea shoud work or if it is leading to failure? Im Far from a finished Model so i cant simulate yet.

Should i rather switch to a fluid model and where do i Define my medium there? in each component individually or once in the Package for all? In the Fluid Library it is nowere stated as an Parameter unlike in Thermal.
Feb-17-21 07:34:19
Category: Programming

WOW,

didnt expect that answer. Whats the deal? does nobody use Medium?

Feb-16-21 22:33:21
Category: Programming

is my question too difficult, is it the wrong place in the forum or is this forum just dead?

i solved my connection problem myself but my question regarding medium.air.moistair is still unsolved ... can anybody explain if the medium.air is usable or bugged.

Feb-10-21 16:19:26
Category: Programming

Hi,

im new with Modelica and some things i cant get to run and i Dont know why.

I want to simulate an Air Conditioning therefore i want to use the medium MoistAir but i dont know where exaktly i need to declare the medium. I found, that the ambient (source block) in Thermal has the parameter Medium but as far as i can see, its not working correctly. Is MoistAir broken like the library medium.air and if so how to work around this?
And if im not mistaken its nesseary to have a Ambient block at beginning of the Medium and at the end. Where do i define the Medium? just Input or both?

Another Question i have is: how can i get variables valued from connectors all the courses dont use connection with medium and the thermal examples dont comment well on that matter.

hope you can help me with my Questions

  • Index
  • » Users
  • » Pyrukar
  • » Profile
You are here: