- Index
- » Users
- » eosilva
- » Profile
Posts
Posts
Hi,
I use in my model the following record:
record BaseGas "Base record for gas definitions"
constant Boolean fixedMixingRatio
"Treat medium as pseudo pure in Modelica if it is a mixture"
annotation (HideResult=true);
constant Integer nc_propertyCalculation(min=1)
"Number of components for fluid property calculations"
annotation (HideResult=true);
final constant Integer nc=if fixedMixingRatio then 1 else
nc_propertyCalculation "Number of components in Modelica models"
annotation (Evaluate=true, HideResult=true);
constant Internals.GasName[nc_propertyCalculation] gasNames
"Array of gas names" annotation (choices);
constant Real[nc_propertyCalculation] mixingRatio_propertyCalculation;
constant Real[nc] defaultMixingRatio=if fixedMixingRatio then {1} else
mixingRatio_propertyCalculation ;
constant Real xi_default[nc - 1]=defaultMixingRatio[1:end - 1]/sum(
defaultMixingRatio) "Default mass fractions" annotation (HideResult=true);
end BaseGas;
I noticed that OpenModelica assumes that the variability of the expression "defaultMixingRatio[1:end - 1]/sum(
defaultMixingRatio)" as "variable" instead of "constant". Is the variability of this expression really variable? If yes, it is possible to convert the variability in Modelica to "constant" so I can suscessfully compile and use this record in my models?
Best Regards,
Erick
By the way, I am using OpenModelica version 1.9.0 Beta 4 release
Hi,
my model (ModelReplacParamCont) contains two elements of type parameter record, one of them is replaceable. In my model tester, I change the type of replaceable parameter, and perform an assignment between these two parameters.
When I call the translateModel in OMshell, I get the following error message:
------------------------------
translateModel(VerktorSizeNullPkg.RepacParam.ModelReplacParamContTester)
"There were errors during translation. Use getErrorString() to see them."
[C:/Users/erick/Desktop/TISC_OM_report/ProblemTester/vektorSizeNull/VerktorSizeNullPkg.mo:109:7-111:74:writable] Error: Component container.param2 of variability PARAM has binding container.param of higher variability VAR.
Error: Error occurred while flattening model VerktorSizeNullPkg.RepacParam.ModelReplacParamContTester
---------------------------------------
Should in this case the redeclared object keep the same variability (in ths case, parameter) ?
Here is my testcode:
package RepacParam "test for variability error in OMshell"
record ModelReplacParamBasis
constant Integer x;
end ModelReplacParamBasis;
record ModelReplacParam1
extends VerktorSizeNullPkg.RepacParam.ModelReplacParamBasis(final x=1);
end ModelReplacParam1;
record ModelReplacParam2
extends VerktorSizeNullPkg.RepacParam.ModelReplacParamBasis(final x=10);
end ModelReplacParam2;
model ModelReplacParamCont
replaceable parameter VerktorSizeNullPkg.RepacParam.ModelReplacParam1
param
constrainedby VerktorSizeNullPkg.RepacParam.ModelReplacParamBasis;
parameter VerktorSizeNullPkg.RepacParam.ModelReplacParamBasis param2 = param;
end ModelReplacParamCont;
model ModelReplacParamContTester
VerktorSizeNullPkg.RepacParam.ModelReplacParamCont container(redeclare
VerktorSizeNullPkg.RepacParam.ModelReplacParam2 param); /*parameter*/
end ModelReplacParamContTester;
end RepacParam;
--------------------------------------------
Thanks in advance,
Erick
Hi,
when I use array indexing, OMshell 1.8.1 (rev. 11758) can't correctly count the number of equations of the model. Here is an example:
record Arrays
parameter Integer n;
Modelica.SIunits.Temperature[ n] T_liq_port;
Modelica.SIunits.Temp_C[ n] T_degC_liq_port;
parameter Boolean includeArrays;
end Arrays;
model loopIndexTester
parameter Boolean includeArrays = true;
parameter Integer sizeArrays = 5;
VerktorSizeNullPkg.Arrays arrayRec(final includeArrays=includeArrays,final n=sizeArrays);
algorithm
arrayRec.T_liq_port[1:end] := ones(sizeArrays)*30;
// arrayRec.T_liq_port[1:sizeArrays] := ones(sizeArrays)*30;
arrayRec.T_degC_liq_port := arrayRec.T_liq_port .- 273.15;
end loopIndexTester;
-------------------
The error message I get:
------------------
messages = "Simulation failed for model: VerktorSizeNullPkg.loopIndexTester
Error: Too few equations, underdetermined system. The model has 6 equation(s) and 11 variable(s)
------------------
If I perform the assignments using a for loop, the translation and simulation are performed correctly.
Thanks in advance,
Erick
Hi,
It is not possible to use any external Modelica function which returns a record object.
I built a simple external function that add two complex numbers. The real and imaginary components of the number are passed as argument of the exernal function. The result is stored in the content of two double variables passed by address:
------ RECORDFKT.h
#ifndef _RECORDFKT_H
#define _RECORDFKT_H
#ifdef RECORDEXT_dll
#define RECORDEXT_Export __declspec(dllexport)
#else
#ifdef __cplusplus
#define RECORDEXT_Export __declspec(dllimport)
#else
#define RECORDEXT_Export
#endif
#endif
#ifdef __cplusplus
#define EXTERN extern "C"
#else
#define EXTERN extern
#endif
EXTERN RECORDEXT_Export int addLibComplexNum(double realX1, double imgX1,double realX2, double imgX2,double* realY,double* imgY);
#endif //_RECORDFKT_H
------ RECORDFKT.cpp
#include "recordFkt.h"
int addLibComplexNum(double realX1, double imgX1,double realX2, double imgX2,double* realY,double* imgY)
{
*realY = realX1 + realX2;
*imgY = imgX1 + imgX2;
return 1;
}
------------------
The Modelica interface, a package, contains a function, a record and a model tester:
----- ExpRecordPkg.mo
package ExpRecordPkg
function addLibComplexNum "function for external test"
input ExpRecordPkg.ComplexRec x1;
input ExpRecordPkg.ComplexRec x2;
output ExpRecordPkg.ComplexRec y = ExpRecordPkg.ComplexRec(0,0);
external "C" addLibComplexNum(x1.realComp,x1.imagComp,x2.realComp,x2.imagComp,y.realComp,y.imagComp) annotation(Library="recordExterFkt");
end addLibComplexNum;
model RecordExtFktTester
parameter ExpRecordPkg.ComplexRec x1 = ExpRecordPkg.ComplexRec(2,2);
parameter ExpRecordPkg.ComplexRec x2 = ExpRecordPkg.ComplexRec(2,1);
ExpRecordPkg.ComplexRec y;
equation
y = ExpRecordPkg.addLibComplexNum(x1,x2);
end RecordExtFktTester;
record ComplexRec
Real realComp;
Real imagComp;
end ComplexRec;
annotation (uses(Modelica(version="3.2")));
end ExpRecordPkg;
----------------
In OM 1.8.1 rev 11758, I get the following error message in OMShell:
>> simulate(ExpRecordPkg.RecordExtFktTester)
record SimulationResult
resultFile = "",
simulationOptions = "startTime = 0.0, stopTime = 1.0, numberOfIntervals = 500, tolerance = 1e-006, method = 'dassl', fileNamePrefix = 'ExpRecordPkg.RecordExtFktTester', storeInTemp = false, noClean = false, options = '', outputFormat = 'mat', variableFilter = '.*', measureTime = false, cflags = '', simflags = ''",
messages = "Simulation failed for model: ExpRecordPkg.RecordExtFktTester
[C:/Users/erick/Desktop/TISC_OM_report/ProblemTester/recordExterFkt/modelica/ExpRecordPkg.mo:5:5-5:37:writable] Warning: Unused input variable x1 in function .ExpRecordPkg.addLibComplexNum.
[C:/Users/erick/Desktop/TISC_OM_report/ProblemTester/recordExterFkt/modelica/ExpRecordPkg.mo:6:5-6:37:writable] Warning: Unused input variable x2 in function .ExpRecordPkg.addLibComplexNum.
[C:/Users/erick/Desktop/TISC_OM_report/ProblemTester/recordExterFkt/modelica/ExpRecordPkg.mo:5:5-5:37:writable] Warning: Unused input variable x1 in function .ExpRecordPkg.addLibComplexNum.
[C:/Users/erick/Desktop/TISC_OM_report/ProblemTester/recordExterFkt/modelica/ExpRecordPkg.mo:6:5-6:37:writable] Warning: Unused input variable x2 in function .ExpRecordPkg.addLibComplexNum.
Error: Error building simulator. Buildlog: gcc -O3 -falign-functions -msse2 -mfpmath=sse -I\"C:/OpenModelica1.8.1//include/omc\" -I. -L\"C:/Users/erick/Desktop/TISC_OM_report/ProblemTester/recordExterFkt/modelica\" -c -o ExpRecordPkg.RecordExtFktTester.o ExpRecordPkg.RecordExtFktTester.c
In file included from ExpRecordPkg.RecordExtFktTester.c:15:
ExpRecordPkg.RecordExtFktTester_functions.c: In function '_ExpRecordPkg_addLibComplexNum':
ExpRecordPkg.RecordExtFktTester_functions.c:30: error: '_y' undeclared (first use in this function)
ExpRecordPkg.RecordExtFktTester_functions.c:30: error: (Each undeclared identifier is reported only once
ExpRecordPkg.RecordExtFktTester_functions.c:30: error: for each function it appears in.)
ExpRecordPkg.RecordExtFktTester_functions.c:32: error: 'struct ExpRecordPkg_ComplexRec' has no member named 'realComp_ext'
ExpRecordPkg.RecordExtFktTester_functions.c:32: error: 'struct ExpRecordPkg_ComplexRec' has no member named 'imagComp_ext'
ExpRecordPkg.RecordExtFktTester_functions.c:32: error: 'struct ExpRecordPkg_ComplexRec' has no member named 'realComp_ext'
ExpRecordPkg.RecordExtFktTester_functions.c:32: error: 'struct ExpRecordPkg_ComplexRec' has no member named 'imagComp_ext'
mingw32-make: *** [ExpRecordPkg.RecordExtFktTester.o] Error 1
Thanks in advance,
Erick
Hi,
This is a for-loop in algorithm section.
Hi,
I have a model that in an event needs to use the previous values of a discrete matrix. However when a try to call the function pre() in a for loop containing an element of a two-dimensional array (with size [nRows,nCols]), I get the following error in OMshell, when translating:
[SimCodeC.tpl:5687:11-5687:11:writable] Error: Template error: Code generation does not support pre( matrix.value[i,j] )
I am using openmodelica 1.8.0 revision 10787.
The same model works in OM when scalar variables and vectors (1-dimensional array) are used instead of matrices.
The same model works with two-dimensional arrays in Dymola 6.1 and 2012.
Could this error be a limitation of this version of OpenModelica?
Thanks in Advance,
Erick
Hi Folks,
I am trying to give a start value to an output of a block with size [nRows, nCols]:
Modelica.Blocks.Interfaces.RealOutput[nRows,nCols] value(final start={(startValues[i,j]*factor[i,j] + offset[i,j]) for j in 1:nCols, i in 1:nRows})
the variables startValues, offset and factor are matrices of parameters, that I initialize with the function ones and zeros
I got unfortunatelly from OM shell the following error message:
"Wrong type on builtin attribute start of type Real[2], expected Real"
"Error: Error occurred while flattening model ... "
How I can correctly initialize my matrix using the expression above?
Thanks in Advance,
Erick
Hi,
I have a model that call external C functions. The translation was suscessful but in simulation I got the message:
"Simulation execution failed for model: name_of_model"
What does that mean exactly? There is a way to debug the simulation or get more information about this error in openmodelica?
I am working with windows vista and the last nightly-builds.
Thanks in advance,
Erick
Thanks.
It works now.
Erick
Hi
Thanks for your answer.
In OMShell I got the error message:
"Error: Class loadModel not found in scope <global scope> (looking for a function or record)."
I am using OpenModelica 1.7.0RC1 at Windows.
TIA,
Erick
Hi,
I am trying to compile a package that I built and compile using Dymola 6.0 and Modelica Standard Library 2.2.1 in OpenModelica. It seems that the default standard Modelica library that is loaded in OpenModelica is version 3.1? Is it possible to change this and compile a model/package that uses Modelica 2.2.1? If yes, how?
Thanks in Advance,
Erick
Hi Folks,
I am trying to build OpenModelica compiler with VS2010 in Windows 7 following the steps described in README-BUILD-RELEASE.txt of the OpenModelica directory (version 1.7.0 Revision 8720 from 20 Apr. 2011). I am using VC7 revision 8678 from 17 Apr. 2011, and OMDev revision 8797 from 03 Mai 2011. As required in the tutorial of README-BUILD-RELEASE.txt, I have installed eclipse SDK (version 3.7.1) and java SDK. I also installed suscessfully the OMToolbox for eclipse. However, when I try to build the project, I get the following errors:
- meta_modelica.h: no such file or directory
I checked and this file exist in my openModelica file. Did I forget any steps? Is it necessary to change anything else in Makefiles that is not described in the tutorial?
Best Regards,
Erick
- Index
- » Users
- » eosilva
- » Profile