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

Problem with derivative calculation

Problem with derivative calculation

I have the piece of code:

Code:


Medium_F.AbsolutePressure p_flow[numberOfFlueSections, numberOfTubeSections + 1](start = p_startFlow);
...
  for i in 1:numberOfFlueSections loop
    for j in 1:numberOfTubeSections loop
...
    C2[i, j] = deltaVFlow * drdp_flow[i, j] ;
...
    p_flow[i, j + 1] = p_flow[i, j] - Dpfric[i, j];
...
    stateFlow[i, j] = Medium_F.setState_ph(p_flow[i, j + 1], h_flow[i, j + 1]);
...
...

it is compiled and calculated normal.
But if I add to the code * der(p_flow[i, j + 1])

Code:


...
C2[i, j] = deltaVFlow * drdp_flow[i, j] * der(p_flow[i, j + 1]);
...

I have "Compilation process failed".

"C:\OpenModelica1.9.3\\MinGW\bin\mingw32-make.exe" -j4 -f MyHRSG.TestOnlyFlowHE.makefile
gcc    -falign-functions -msse2 -mfpmath=sse     -I"C:/OpenModelica1.9.3//include/omc/c" -I. -DOPENMODELICA_XML_FROM_FILE_AT_RUNTIME  -c -o MyHRSG.TestOnlyFlowHE.o MyHRSG.TestOnlyFlowHE.c
gcc    -falign-functions -msse2 -mfpmath=sse     -I"C:/OpenModelica1.9.3//include/omc/c" -I. -DOPENMODELICA_XML_FROM_FILE_AT_RUNTIME  -c -o MyHRSG.TestOnlyFlowHE_functions.o MyHRSG.TestOnlyFlowHE_functions.c
gcc    -falign-functions -msse2 -mfpmath=sse     -I"C:/OpenModelica1.9.3//include/omc/c" -I. -DOPENMODELICA_XML_FROM_FILE_AT_RUNTIME  -c -o MyHRSG.TestOnlyFlowHE_records.o MyHRSG.TestOnlyFlowHE_records.c
gcc    -falign-functions -msse2 -mfpmath=sse     -I"C:/OpenModelica1.9.3//include/omc/c" -I. -DOPENMODELICA_XML_FROM_FILE_AT_RUNTIME  -c -o MyHRSG.TestOnlyFlowHE_01exo.o MyHRSG.TestOnlyFlowHE_01exo.c
gcc    -falign-functions -msse2 -mfpmath=sse     -I"C:/OpenModelica1.9.3//include/omc/c" -I. -DOPENMODELICA_XML_FROM_FILE_AT_RUNTIME  -c -o MyHRSG.TestOnlyFlowHE_02nls.o MyHRSG.TestOnlyFlowHE_02nls.c
gcc    -falign-functions -msse2 -mfpmath=sse     -I"C:/OpenModelica1.9.3//include/omc/c" -I. -DOPENMODELICA_XML_FROM_FILE_AT_RUNTIME  -c -o MyHRSG.TestOnlyFlowHE_03lsy.o MyHRSG.TestOnlyFlowHE_03lsy.c
MyHRSG.TestOnlyFlowHE_03lsy.c: In function 'MyHRSG_TestOnlyFlowHE_initialLinearSystem':
MyHRSG.TestOnlyFlowHE_03lsy.c:167: error: 'MyHRSG_TestOnlyFlowHE_functionJacNLSJac7_column' undeclared (first use in this function)
MyHRSG.TestOnlyFlowHE_03lsy.c:167: error: (Each undeclared identifier is reported only once
MyHRSG.TestOnlyFlowHE_03lsy.c:167: error: for each function it appears in.)
MyHRSG.TestOnlyFlowHE_03lsy.c:168: error: 'MyHRSG_TestOnlyFlowHE_initialAnalyticJacobianNLSJac7' undeclared (first use in this function)
MyHRSG.TestOnlyFlowHE_03lsy.c:180: error: 'MyHRSG_TestOnlyFlowHE_functionJacNLSJac8_column' undeclared (first use in this function)
MyHRSG.TestOnlyFlowHE_03lsy.c:181: error: 'MyHRSG_TestOnlyFlowHE_initialAnalyticJacobianNLSJac8' undeclared (first use in this function)
mingw32-make: *** [MyHRSG.TestOnlyFlowHE_03lsy.o] Error 1
mingw32-make: *** Waiting for unfinished jobs....
Compilation process failed. Exited with code 2.


Why is this happening? Can I calculate the derivative without der()?

Edited by: Makumazan - Nov-04-15 14:49:14

Re: Problem with derivative calculation

Hi again.
I replaced der(p_flow[i, j + 1]) to (p_flow[i, j + 1] - delay(p_flow[i, j + 1], 0.2)) / 0.2, (where 0.2 - time interval), and it works. But I'm not sure that this replacing is tantamount  current/sad .

Re: Problem with derivative calculation

Can I in the model use: stoptime, startime etc? Is it possible to implement such a line: parameter Real timeStep = (stopTime-startTime) / numberOfIntervals?

Re: Problem with derivative calculation

No, that is not possible. startTime/stopTime/numberOfIntervals only exist inside experiment annotation.

There are 0 guests and 0 other users also viewing this topic
You are here: