- Index
- » Users
- » spinnau
- » Profile
Posts
Posts
Parameters will be handled with fixed=true by default. Thus, if you don't set parameters explicitly, the start values (zero for C and G) will be used. If you want to compute parameters in the initial equation section, then you have to set these parameters to fixed=false. Otherwise the initial conditions are over-determined.
Code:
Modelica.Thermal.HeatTransfer.Components.HeatCapacitor cellElement[N-2, M-2, K-2](each C(fixed=false));
From your model description, the valves for the outflow of both tanks are controlled with hysteresis. The outlet valve should be opened as soon as the maximum level in a tank is reached and only close again when the level has fallen to the minimum.
You have used an if-clause for the controller, but that doesn't work. Starting at time t=0 with an empty tank 1 with a continuous inflow and closed outlet valve, the water level raises until the if expression h1>=max1 becomes true for the first time and the outlet valve will be opened. As the if-clause will be evaluated whenever any of the conditional expressions changes, it will switch very fast between the 'if h1>=max1'-branch and the else-branch and cause the chattering. The equation 'o1=o1' in the else-branch might also cause problems.
To implement the hysteresis, the last state of the valve must be taken into account. For this, a when statement is needed, that only activates equations when the defined condition becomes true. For your model a solution could be:
Code:
model TankSystem
parameter Real s=1.0;
Real h1(start=0.0);
Real o1;
parameter Real of1=2.0;
parameter Real min1=20.0;
parameter Real max1=80.0;
Real h2(start=0.0);
Real o2;
parameter Real of2=3.0;
parameter Real min2=20.0;
parameter Real max2=80.0;
equation
der(h1) = s - o1;
der(h2) = o1 - o2;
// control valve 1 for outflow of tank 1 with hysteresis
when h1>max1 then
o1 = of1;
elsewhen h1<min1 then
o1 = 0;
end when;
// control valve 2 for outflow of tank 2 with hysteresis
when h2>max2 then
o2 = of2;
elsewhen h2<min2 then
o2 = 0;
end when;
end TankSystem;
* Create a new modelica package "File | New Modelica Class"
* Select the model you want to duplicate from the MSL, right-click and choose "Duplicate"
* Click the "Browse" button
* In the "Select Path" dialog delete the path from the filter field (upper text entry box)
* Now all your loaded Modelica libraries including your newly created package should be shown
* Select your package
Possibly the duplicated model contains some relative references to other name spaces, that needs to be changed to absolute paths for the model to work, e.g.
Code:
Interfaces.HeatPort_a port
// change to
Modelica.Thermal.HeatTransfer.Interfaces.HeatPort_a port
The wrong calculation of the mixture molar mass (e.g. with the MixtureGasNasa model) is a known issue: Ticket #2858. In this attachment of the ticket, you can find possible workarounds to properly calculate the molar mass of the gas mixture.
The system libraries will be loaded in OMEdit as read-only. If you need something changed, the normal way is to inherit/extend from this components in your own package (or even copy the component to your package) and make your changes there.
If you really want to edit the Modelica standard library, then in principle you could change the files in the system path (e.g. /usr/lib/omlibrary/Modelica 3.2.2 on linux) with a text editor, but I would recommend to make a working copy of it to your home directory. In OMEdit you can then unload the Modelica standard library with a right-click in the libraries browser and then load your working copy instead, which will then be writable. If you need this permanently, you can remove Modelica from the system libraries in the OMEdit options and add your working copy as an user library (please see screenshot attached).
Connectors have to be defined with a balanced set of potential variables and flow variables (defined with the flow keyword). In OMEdit you should also get this warning:
Code:
Translation Warning
[SimplefiedTwoTanks: 21:1-23:18]: Connector .SimplefiedTwoTanks.FlowConnector is not balanced: The number of potential variables (1) is not equal to the number of flow variables (0).
As the flow rate depends on the pressure, your connector should implement the pressure as a potential variable and the rate as flow variable, e.g.
Code:
connector FlowConnector
flow Real rate; //flow rate of the connector
Real p; // pressure
end FlowConnector;
You could find an introduction about connectors at Modelica by Example.
By default, the result file name is inherited from the model name, e.g. "package.my_model_res.mat". Thus, at the new simulation run the old result file will be overwritten. There are two possible solutions for your problem:
1. Change the name of the result file for each new simulation in the output tab of the simulation settings dialog
→ Simulation | Simulation Setup | Output | Result File (Optional)
2. Duplicate your model and make your changes in the copy
In principle your downloaded version of lpsolve should also work if the binary is compatible to your systems libraries. But you have to add the include and linker paths to CFLAGS/CPPFLAGS and LDFLAGS so that the header files and the shared library will be found:
Code:
$ export CPPFLAGS="$CPPFLAGS -I/home/lib/lpsolve"
$ export LDFLAGS="$LDFLAGS -L/home/lib/lpsolve"
$ make
The best thing is to use the package manager of your linux distribution to install the dependency packages. On openSUSE the needed packages might be lpsolve and/or liblpsolve55-0 and can be installed e.g. from the terminal with zypper
Code:
$ zypper install lpsolve
Hello vlle,
it looks like you missed to install "lpsolve55" package as a dependency. You will find a list with the needed dependencies at https://github.com/OpenModelica/OpenModelica
There may be something wrong with your installation. From your build messages it seems that the PKG_CHECK_MODULES macro cannot be found, which is defined in pkg-config's file "pkg.m4". If I uninstall pkg-config, then I will get the same error as you.
Do you have different versions of autoconf installed? Or installed autoconf and pkg-config with different prefix? The file "pkg.m4" should be located in the directory returned by the command:
Code:
$ aclocal --print-ac-dir
Are you sure there are no error messages? As you are running make parallelized with the -j8 option, it is sometimes difficult to find the error in the output. You can try to build omc only, by running
Code:
> make omc
The compile error for OMOptim regarding omc_communication.idl is gone now, thanks to sjoelund's fix.
I have also created a PKGBUILD for Arch LInux, that avoids cloning the complete repository if the package is rebuilt:
PKGBUILD.txt
OMOptim.desktop
OMNotebook.desktop
OMEdit.desktop
- Index
- » Users
- » spinnau
- » Profile