- Index
- » Users
- » swaroop.katta
- » Profile
Posts
Posts
Hi,
Is this issue sorted? I'm getting the same error!
-Swaroop
Hi,
I wrote a function HVapId to calculate vapor enthaply. Used it in a model and i works fine. I wrote HLiqId for liquid enthalpy which inturn calls HvapId for calculations. These 2 functions worked normally in a model.
But while i'm using it in a different model, compilation process fails.
So, I changed algorithm in HvapId and saved it as HvapId1. So, the new model works with HvapId and HLiqId (which uses HVapId1 instead of HVapId). both the functions HvapId and HvapId1 have same inputs and output just a different algo. The only problem is when I call HvapId from HliqId the compilation fails. If I call HVapId1 from HLiqId it runs! But the algorithm in HVapId1 fails for some cases, so I want to use HVapId.
Since both the functions HVapId and HVapId1 have same inputs, I don't understand why there is an issue with compilation. That too only for a different model.
I'll try to reproduce the error with a simple model and post the model.
-Swaroop
Hi,
What does connectorSizing do in the Dialog annotation? I read documentation from here and am not sure how it can be used. Are there any examples where i can see what this attribute is doing specifically?
Is it the case like in if I want to specify 'n' components where n is an integer and these components should be selected from a list of components from drop down menus in parameters window, then should I specify 'n' as an integer parameter with connectorSizing = true ?
any help is appreciated.
-Swaroop.
Hi,
I'm trying to access some constants from a package that i created. While doing so I get the following error "Real Alias variable c.Tc not found".
.I have constants in 'Database' package, I want to edit 'data' model so that i can take only required things from 'Database' and use them in 'testdata' model. Below is the code
Code:
class paramtertest
package Database
model General_Properties
constant Real Tc;
end General_Properties;
model Hydrogen
extends General_Properties(Tc = 30);
end Hydrogen;
model Helium
extends General_Properties(Tc = 40);
end Helium;
end Database;
model data
constant Database.Hydrogen a ;
end data;
model testdata
Real b;
constant Database.General_Properties c = data.a;
equation
b= c.Tc;
end testdata;
end paramtertest;
how to assign Tc of Hydrogen to variable b?
Hi,
in the model below both H and h should have the same value. starting algorithm by giving value to protected variable Ent gives wrong value (H = 0), but commenting that line 9 gives warning that variable "Ent was used before it was given value" but gives correct result h = H. Can someone look into this?
Code:
model functiontest
function hv
input Real Tc;
input Real T;
output Real Ent2;
protected Real temp, Ent;
algorithm
temp := 298.15;
Ent :=0; //if we comment this and run, we'll get correct result
if T> 298.15 then
while temp < T loop
Ent := Ent + (temp) * 1;
temp := temp + 1;
end while;
Ent2 := Ent;
else
while temp > T loop
Ent := Ent + (temp) * 1;
temp := temp - 1;
end while;
Ent2 := -Ent;
end if;
end hv;
function hl
input Real Tc;
input Real T;
output Real Ent1;
algorithm
if T<Tc then
Ent1 := hv(Tc, T) + (1-T/Tc)^2;
else
Ent1 := hv(Tc, T); //this is true for T = 400 and Tc = 33
end if;
end hl;
parameter Real Tc = 33, T = 400;
Real H, h;
equation
H = hv(Tc, T);
h = hl(Tc, T);
end functiontest;
Hi, I made two functions HliqId and HvapId. When T > Tc (33K in this case), It is written in HliqId that output will be same as HvapId. When I try to calculate at T = 400K (>33K), Both the functions should give same result. But HliqId which gives correct result while calculating directly with HvapId gives 0 as output! (weird since HliqId itself calculates from HvapId). Can someone help me here!
Im attaching the files here. Func package has functions required (HliqId and HvapId), Databse has constants that are used in these functions. enthalpytest calculates H from HvapId and h from HliqId at T = 400. H and h should be same but modelica gives h = 2957.99 and H =0.
-Swaroop
Database.mo
Func.mo
enthalpytest.mo
Functions.mo
steadystate.mo
dynamic.mo
pfa files
No, I did not use 'fixed = true'. I just gave whatever initial values that I gave for steady state model. I think parameters have default values of 'fixed = true' right? Is there any reason why they are being changed to zero?
-Swaroop
Hi,
I'm trying to simulate a rather highly non linear dynamic system. I started with a steady state model and got the values. I then made a dynamic model and set the derivatives to zero in the 'initial equation' section. I gave the initial guesses based on the steady state model result. Now, when I run the dynamic model, it gives the following warning:
Code:
[1] 02:46:30 Translation Notification
It was not possible to analyze the given system symbolically, because the relevant equations are part of an algebraic loop. This is not supported yet.
[2] 02:46:30 Translation Warning
Assuming redundant initial conditions for the following 30 initial equations:
P[5] = P_condenser + 10.0 * Pressure_drop + (P_condenser + Pressure_drop - (P_condenser + 10.0 * Pressure_drop)) * 0.4444444444444444
comp[2].HOV[1] = propanol.HOV[1]
comp[2].VapCp[6] = propanol.VapCp[6]
comp[2].VP[2] = propanol.VP[2]
comp[1].VP[2] = ethanol.VP[2]
comp[2].LiqDen[1] = propanol.LiqDen[1]
comp[2].LiqDen[4] = propanol.LiqDen[4]
comp[2].HOV[2] = propanol.HOV[2]
comp[1].HOV[2] = ethanol.HOV[2]
comp[2].VP[4] = propanol.VP[4]
comp[2].HOV[5] = propanol.HOV[5]
comp[2].HOV[6] = propanol.HOV[6]
comp[2].LiqDen[3] = propanol.LiqDen[3]
comp[2].VP[3] = propanol.VP[3]
comp[2].VP[5] = propanol.VP[5]
comp[1].Tc = ethanol.Tc
comp[2].VP[6] = propanol.VP[6]
comp[2].LiqDen[6] = propanol.LiqDen[6]
comp[2].LiqDen[5] = propanol.LiqDen[5]
comp[2].HOV[4] = propanol.HOV[4]
comp[1].VP[3] = ethanol.VP[3]
comp[1].VP[4] = ethanol.VP[4]
comp[1].VP[5] = ethanol.VP[5]
comp[1].VP[6] = ethanol.VP[6]
comp[2].VapCp[4] = propanol.VapCp[4]
comp[1].HOV[4] = ethanol.HOV[4]
comp[1].HOV[5] = ethanol.HOV[5]
comp[1].HOV[6] = ethanol.HOV[6]
comp[1].VapCp[6] = ethanol.VapCp[6]
comp[2].Tc = propanol.Tc
[3] 02:46:30 Translation Warning
Iteration variables with default zero start attribute in torn nonlinear equation system:
$DER.x[2,2]:DUMMY_DER(fixed = false ) .DistillationDynamic, .Real type: Real [10,2]
$DER.x[3,2]:DUMMY_DER(fixed = false ) .DistillationDynamic, .Real type: Real [10,2]
$DER.x[4,2]:DUMMY_DER(fixed = false ) .DistillationDynamic, .Real type: Real [10,2]
$DER.x[5,2]:DUMMY_DER(fixed = false ) .DistillationDynamic, .Real type: Real [10,2]
$DER.x[6,2]:DUMMY_DER(fixed = false ) .DistillationDynamic, .Real type: Real [10,2]
$DER.x[7,2]:DUMMY_DER(fixed = false ) .DistillationDynamic, .Real type: Real [10,2]
$DER.x[8,2]:DUMMY_DER(fixed = false ) .DistillationDynamic, .Real type: Real [10,2]
$DER.x[9,2]:DUMMY_DER(fixed = false ) .DistillationDynamic, .Real type: Real [10,2]
$DER.x[10,2]:DUMMY_DER(fixed = false ) .DistillationDynamic, .Real type: Real [10,2]
$DER.x[1,2]:DUMMY_DER(fixed = false ) .DistillationDynamic, .Real type: Real [10,2]
comp[1].VP[5]:VARIABLE() = ethanol.VP[5] .DistillationDynamic, .Chemsep_Database.General_Properties, .Real type: Real [6]
comp[2].HOV[6]:VARIABLE() = propanol.HOV[6] .DistillationDynamic, .Chemsep_Database.General_Properties, .Real type: Real [6]
comp[2].VapCp[6]:VARIABLE() = propanol.VapCp[6] .DistillationDynamic, .Chemsep_Database.General_Properties, .Real type: Real [6]
comp[2].HOV[4]:VARIABLE() = propanol.HOV[4] .DistillationDynamic, .Chemsep_Database.General_Properties, .Real type: Real [6]
$DER.T[10]:DUMMY_DER(fixed = false ) .DistillationDynamic, .Real type: Real [10]
comp[2].VP[3]:VARIABLE() = propanol.VP[3] .DistillationDynamic, .Chemsep_Database.General_Properties, .Real type: Real [6]
$DER.T[9]:DUMMY_DER(fixed = false ) .DistillationDynamic, .Real type: Real [10]
comp[2].HOV[2]:VARIABLE() = propanol.HOV[2] .DistillationDynamic, .Chemsep_Database.General_Properties, .Real type: Real [6]
comp[2].LiqDen[1]:VARIABLE() = propanol.LiqDen[1] .DistillationDynamic, .Chemsep_Database.General_Properties, .Real type: Real [6]
comp[2].LiqDen[3]:VARIABLE() = propanol.LiqDen[3] .DistillationDynamic, .Chemsep_Database.General_Properties, .Real type: Real [6]
comp[1].VP[3]:VARIABLE() = ethanol.VP[3] .DistillationDynamic, .Chemsep_Database.General_Properties, .Real type: Real [6]
comp[2].VP[5]:VARIABLE() = propanol.VP[5] .DistillationDynamic, .Chemsep_Database.General_Properties, .Real type: Real [6]
comp[2].LiqDen[4]:VARIABLE() = propanol.LiqDen[4] .DistillationDynamic, .Chemsep_Database.General_Properties, .Real type: Real [6]
comp[1].Tc:VARIABLE() = ethanol.Tc .DistillationDynamic, .Chemsep_Database.General_Properties, .Real type: Real [2]
comp[1].VP[6]:VARIABLE() = ethanol.VP[6] .DistillationDynamic, .Chemsep_Database.General_Properties, .Real type: Real [6]
$DER.T[5]:DUMMY_DER(fixed = false ) .DistillationDynamic, .Real type: Real [10]
comp[2].HOV[5]:VARIABLE() = propanol.HOV[5] .DistillationDynamic, .Chemsep_Database.General_Properties, .Real type: Real [6]
$DER.T[7]:DUMMY_DER(fixed = false ) .DistillationDynamic, .Real type: Real [10]
comp[1].VapCp[6]:VARIABLE() = ethanol.VapCp[6] .DistillationDynamic, .Chemsep_Database.General_Properties, .Real type: Real [6]
comp[1].HOV[6]:VARIABLE() = ethanol.HOV[6] .DistillationDynamic, .Chemsep_Database.General_Properties, .Real type: Real [6]
$DER.T[8]:DUMMY_DER(fixed = false ) .DistillationDynamic, .Real type: Real [10]
$DER.M[7]:VARIABLE() .DistillationDynamic, .Real type: Real [10]
P[5]:VARIABLE() = P_condenser + 10.0 * Pressure_drop + (P_condenser + Pressure_drop - (P_condenser + 10.0 * Pressure_drop)) * 0.4444444444444444 .DistillationDynamic, .Real type: Real [10]
$DER.M[10]:VARIABLE() .DistillationDynamic, .Real type: Real [10]
comp[2].LiqDen[6]:VARIABLE() = propanol.LiqDen[6] .DistillationDynamic, .Chemsep_Database.General_Properties, .Real type: Real [6]
comp[2].LiqDen[5]:VARIABLE() = propanol.LiqDen[5] .DistillationDynamic, .Chemsep_Database.General_Properties, .Real type: Real [6]
$DER.T[2]:DUMMY_DER(fixed = false ) .DistillationDynamic, .Real type: Real [10]
comp[1].HOV[5]:VARIABLE() = ethanol.HOV[5] .DistillationDynamic, .Chemsep_Database.General_Properties, .Real type: Real [6]
comp[1].HOV[2]:VARIABLE() = ethanol.HOV[2] .DistillationDynamic, .Chemsep_Database.General_Properties, .Real type: Real [6]
$DER.T[3]:DUMMY_DER(fixed = false ) .DistillationDynamic, .Real type: Real [10]
comp[2].HOV[1]:VARIABLE() = propanol.HOV[1] .DistillationDynamic, .Chemsep_Database.General_Properties, .Real type: Real [6]
$DER.T[6]:DUMMY_DER(fixed = false ) .DistillationDynamic, .Real type: Real [10]
$DER.T[4]:DUMMY_DER(fixed = false ) .DistillationDynamic, .Real type: Real [10]
comp[2].Tc:VARIABLE() = propanol.Tc .DistillationDynamic, .Chemsep_Database.General_Properties, .Real type: Real [2]
$DER.T[1]:DUMMY_DER(fixed = false ) .DistillationDynamic, .Real type: Real [10]
comp[1].HOV[4]:VARIABLE() = ethanol.HOV[4] .DistillationDynamic, .Chemsep_Database.General_Properties, .Real type: Real [6]
$DER.M[3]:VARIABLE() .DistillationDynamic, .Real type: Real [10]
comp[2].VP[4]:VARIABLE() = propanol.VP[4] .DistillationDynamic, .Chemsep_Database.General_Properties, .Real type: Real [6]
comp[2].VP[6]:VARIABLE() = propanol.VP[6] .DistillationDynamic, .Chemsep_Database.General_Properties, .Real type: Real [6]
comp[2].VapCp[4]:VARIABLE() = propanol.VapCp[4] .DistillationDynamic, .Chemsep_Database.General_Properties, .Real type: Real [6]
comp[2].VP[2]:VARIABLE() = propanol.VP[2] .DistillationDynamic, .Chemsep_Database.General_Properties, .Real type: Real [6]
comp[1].VP[2]:VARIABLE() = ethanol.VP[2] .DistillationDynamic, .Chemsep_Database.General_Properties, .Real type: Real [6]
comp[1].VP[4]:VARIABLE() = ethanol.VP[4] .DistillationDynamic, .Chemsep_Database.General_Properties, .Real type: Real [6]
$DER.M[1]:VARIABLE() .DistillationDynamic, .Real type: Real [10]
$DER.M[4]:VARIABLE() .DistillationDynamic, .Real type: Real [10]
$DER.M[2]:VARIABLE() .DistillationDynamic, .Real type: Real [10]
$DER.M[5]:VARIABLE() .DistillationDynamic, .Real type: Real [10]
$DER.M[6]:VARIABLE() .DistillationDynamic, .Real type: Real [10]
$DER.M[8]:VARIABLE() .DistillationDynamic, .Real type: Real [10]
$DER.M[9]:VARIABLE() .DistillationDynamic, .Real type: Real [10]
Here almost all the values that are being set to default zero are parameters for which the values are available at t=0, but still they are being dropped.
(the system is exactly same as steady state one, except derivatives are added but they are kept as zero in initial equation section)
Any ideas how to solve this issue?
-Swaroop
Hi again,
Here are the things that went wrong on my side: I declared an array of size 10 but in for loop i used 11th element of that array in an equation. Checking and instantiation didn't consider that 11th element (that variable was simply neglected ). However while compiling it considered that variable which was not declared in the first place (I checked C file). So, I made a change to that equation and it worked fine.
I think it would be better if OM gives a warning that array size has been extended.
Thanks,
Swaroop.
Hi,
I'm sorry.
Seems like changing the attachment is not working! can you please change line 19 in Functions.mo package from "Thermodynamic_Functions.HV()" to just "Functions.HV()" (remove "Thermodynamic_") and run distillation.mo
-Swaroop
distillation.mo
Hi,
Functions required are in Functions package, Database has values required for those functions, Model is distillation. If I simulate distillation.mo, it fails at compilation.
-Swaroop
Hi,
I'm trying to develop a distillation model. Checked the model and the no. of variables = no. of equations. Since the model is highly non linear, i gave initial guesses for some variables. When I tried to simulate, OM couldn't compile it. I'm attaching the screenshot for the same.
Any possible reasons for it? (do the start values effect compilation?)
-Swaroop
Hi,
Is there a way to optimize a given function value given some constraints in openmodelica models(may be through OMoptim?)
you can use time which is a built in variable,
model Plot
Real y;
equation
y=time;
end Plot;
Hi,
Is there a way to define non time derivatives? So that d/dt and d/dx can be used in a model.
Also can boundary value problems be solved using modelica?
-Swaroop.
Hi,
Is there any way to print real values to output window during the simulation?
Modelica.Utilities.Streams.print("message") doesn't seem to work with real values?
-Swaroop
Hi, I have used external functions for serial communication.
Below is code to create serial object
Code:
class Serial
extends ExternalObject;
encapsulated function constructor
input Integer PortNum;
output SerialPort Sport;
external "c" Sport=openport(PortNum);
annotation (Library="cfile2");
end constructor;
encapsulated function destructor
input SerialPort Sport;
output Integer i;
external "c" i=closeport(Sport);
annotation (Library="cfile2");
end destructor;
end Serial;
You can use above object as
Code:
model PIcontroller
import Serial;
Serial sp = Serial(3); //opens serial port 3 and keeps it open
equation
.
.
end PIcontroller;
Hope this helps.
Hi all,
I'm trying to solve a steady state problem which i intend to change to dynamic model later with steady state conditions as initial conditions.
To get the steady state values i have all the equations required. But there seems to be an issue in solving non linear system. (Matrix singular). can anyone help?
Below is the test code.
Code:
model test
parameter Integer N = 3, NOC = 2, P0 = 130325, FT = 2;
parameter Real F[N]={0,100,0}, z[NOC,N]=[0,0.5,0;0,0.5,0], R = 6, D=40;
Real B,L[N], V[N], y[NOC, N], x[NOC, N]/*(each start = 0.5,each min =0)*/, p[N], T[N](each start =350, each nominal= 1), pi[NOC,N],L0;
Real Qc,Qb,Hif[NOC,N],HiL[NOC,N],HiV[NOC,N],H0L[NOC];
equation
F[FT]=D+B;
F[FT]*sum(Hif[:,FT].*z[:,FT])+Qb=Qc+D*sum(H0L[:].*y[:,1])+B*sum(HiL[:,N].*x[:,N]);
for j in 1:N loop
sum(y[:,j])=1;
sum(x[:,j])=1;
p[j]=P0+690*j;
y[:,j]=pi[:,j].*x[:,j]/p[j];
pi[1,j]=10*T[j]+100/T[j] + T[j]^2;
pi[2,j]=20*T[j]+10/T[j] + T[j]^2;
HiV[1,j]=40*(T[j]-298)+4000;
HiV[2,j]=60*(T[j]-298)+8000;
HiL[1,j]=40*(T[j]-298);
HiL[2,j]=60*(T[j]-298);
Hif[1,j]=40*(398-298);
Hif[2,j]=60*(T[j]-298);
end for;
L0=R*D;
V[1]=D+L0;
V[1].*y[:,1] + L[1].*x[:,1]=L0.*y[:,1] + V[2].*y[:,2];
Qc=V[1]*sum(HiV[:,1].*y[:,1])-V[1]*sum(H0L[:].*y[:,1]);
H0L[1]=40*(305-298);
H0L[2]=60*(305-298);
V[N]+L[N] = L[N-1];
L[N]=B;
Qb= V[N]*sum(HiV[:,N].*y[:,N])+ B*sum(HiL[:,N].*x[:,N])-L[N-1]*sum(HiL[:,N-1].*x[:,N-1]) ;
for j in 2:N-1 loop
L[j-1].*x[:,j-1] + V[j+1].*y[:,j+1] + F[j].*z[:,j] = L[j].*x[:,j] + V[j].*y[:,j]+F[j].*z[:,j];
L[j-1]*sum(HiL[:,j-1].*x[:,j-1]) + V[j+1]*sum(HiV[:,j+1].*y[:,j+1]) + F[j]*sum(Hif[:,j].*z[:,j]) = L[j]*sum(HiL[:,j].*x[:,j]) + V[j]*sum(HiV[:,j].*y[:,j]);
end for;
end test;
Hi,
I have several classes with different data sets in a package.
Example
Code:
package comptest
model c1
parameter Real a = 1;
parameter Real b = 2;
parameter Real c = 3;
end c1;
model c2
parameter Real a = 4;
parameter Real b = 5;
parameter Real c = 6;
end c2;
model c3
parameter Real a = 7;
parameter Real b = 8;
parameter Real c = 9;
end c3;
model c4
parameter Real a = 10;
parameter Real b = 11;
parameter Real c = 12;
end c4;
end comptest;
I want to use a parameter (as enum) to select a particular class by defining a Type.
Code:
type compound = enumeration(c1, c2, c3, c4, c5, c6, c7, c8);
We can get the string from the enumeration item, however I'm not able to use that string to open that class. Any ideas on this?
something like this..
Code:
model enumtest
parameter compound testcompound1 "compound1" annotation(Dialog(tab = "input", group = "compounds"));
parameter compound testcompound2 "compound2" annotation(Dialog(tab = "input", group = "compounds"));
//use the values of a,b,c of respective compounds //
end enumtest
Regards,
Swaroop
Hi,
I am trying to communicate with arduino through Serial port using Modelica_DeviceDrivers package. I'm successfully sending the data (sample code below).
Code:
model arduino
parameter String Device_name = "COM5";
import Modelica_DeviceDrivers.Communication.SerialPort;
import Modelica_DeviceDrivers.Utilities.Types.SerialBaudRate;
import Modelica_DeviceDrivers.Utilities.Types.ByteOrder;
import Modelica_DeviceDrivers.Communication.SerialPort_;
import Modelica_DeviceDrivers.Packaging.SerialPackager;
import Modelica_DeviceDrivers.Packaging.SerialPackager_;
parameter SerialBaudRate baud = SerialBaudRate.B9600;
parameter ByteOrder byteorder = ByteOrder.BE;
SerialPort OpenPort = SerialPort.constructor(Device_name, 16 * 1024, 0, 0, baud);
SerialPackager pkg = SerialPackager.constructor(4608);
parameter Integer S1[1] = {50};
algorithm
SerialPackager_.setPos(pkg, 0);
SerialPackager_.addInteger(pkg, S1, byteorder);
SerialPort_.sendTo(OpenPort, pkg, 4608);
end arduino;
But I'm not able to receive data from arduino. (See the code below).
Code:
model arduinoread
parameter String Device_name = "COM5";
import Modelica_DeviceDrivers.Communication.SerialPort;
import Modelica_DeviceDrivers.Utilities.Types.SerialBaudRate;
import Modelica_DeviceDrivers.Utilities.Types.ByteOrder;
import Modelica_DeviceDrivers.Communication.SerialPort_;
import Modelica_DeviceDrivers.Packaging.SerialPackager;
import Modelica_DeviceDrivers.Packaging.SerialPackager_;
parameter SerialBaudRate baud = SerialBaudRate.B9600;
parameter ByteOrder byteorder = ByteOrder.LE;
SerialPort readPort = SerialPort.constructor(Device_name, 16 * 1024, 0, 1, baud);
SerialPackager pkg = SerialPackager.constructor(4608);
//SerialPackager pkg1 = SerialPackager.constructor(4608);
//parameter Integer S1[1] = {50};
//Real n;
Integer I[16];
algorithm
SerialPackager_.setPos(pkg, 0);
SerialPort_.read(readPort,pkg);
//n=SerialPort_.getReceivedBytes(readPort);
I:=SerialPackager_.getInteger(pkg,16,byteorder);
end arduinoread;
Can anyone help me regarding this?
Hi,
I'm trying to communicate with serial port using Modelica_DeviceDrivers package. I have given all the inputs required for the functions in it. Basically it communicates through external Code. But when I simulate it I get the following error "undefined reference to `_imp__pthread" . Attached is the screenshot of the error. Can anyone help me sort this out?
Hi,
I'm new to OpenModelica. I'm trying to communicate with a hardware using serial port. Data must be sent and received in the form of ASCII codes. I'm trying to use the Modelica_DeviceDrivers package. Can someone guide me through the steps or better provide an example how it is done.
Thank you.
- Index
- » Users
- » swaroop.katta
- » Profile