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

Partial Differential Equations in OM

Partial Differential Equations in OM

I am attempting to build a  model first to prove the usage of the pder operator in modelica to perform partial derivatives, and am looking for help in implementing this function and seeing if it actually works as stated. 

Since the text by Paul Fritzon is a few years old and discusses the use of Modelica 2.1, it is difficult to figure out from the literature what functions are actually available at this time to perform these PDEs.  There are a number of papers that discuss "methods" of dealing with partial differential equations in modelica, but for realistic purposes, I am curious to see what exactly is needed in order to perform these types of analysis.  Such PDEs seem like they should be computable in OM since they show up in a number of situations and are needed for most real-world physical phenomena. 

The sample model given by the Fritzon book is as below for 1-dimensional heat flow in a conducting rod:

model HeatLine1D
  import DifferentialOperators1D.pder;
  parameter DomainLine1DGrid rod;
  FieldLine1DGrid u (domain = rod, FieldValueType=SI.Temperature);
equation
  der(u) = pder(u, D.x2) in rod.interior;
  u = 20*sin(PI*time/12)+300 in rod.left;
  pder(u, D.x) = 0 in rod.right;
end HeatLine1D;

Any help in this area is extremely helpful and would be of great value to many. 

Thanks and I look forward to any input you can provide.

Re: Partial Differential Equations in OM

You're out of luck.

From Peter Fritzson's book (8.5 Partial Differential Equations):
This section describes a generalized in operator that at the time of this writing is not yet formally accepted in the Modelica language specification

From the Modelica 3.2 specification (Preface):
There are no language elements to describe directly partial differential equations, although some types of discretized partial differential equations can be reasonably defined, e.g., based on the finite volume method and there are Modelica libraries to import results of finite-element programs.

Re: Partial Differential Equations in OM

hello
is it possible to model Differential Equations in OpenModelica? I mean without dealing with partial concepts.

Re: Partial Differential Equations in OM

Here is an example on how to solve the heat transfer equation in OMNotebook. Is it possible to reduce the simulation time with some sort of simulation options?

function array2time 
  //this function gets an array of data and the time
  //it returns a time dependend stepwise result
  //each array value corresponds to a specific time interval
  input Real array[:];
  input Real time;
  output Real result;
protected
Integer array_length;
Real delta_time;
Real stop_time;
algorithm
stop_time:= 1;
array_length := size(array,1); //number of values
delta_time:=stop_time/(array_length-1); //size of time interval
for k in 1:array_length loop
  if time >delta_time*(k-1)-delta_time/2 and time <= delta_time*k-delta_time/2 then
   result:=array[k];
  end if;
end for; 
  //if time >=stop_time-delta_time/2 then
  // result:=array[array_length-1];
  //end if; 
end array2time;

loadModel(Modelica);

model HeatTransfer "One Dimensional Heat Transfer"
import Modelica.SIunits;

//Configuration parameters
parameter Integer n=100 "Number of Nodes";
parameter SIunits.Density rho=1 "Material Density";
parameter SIunits.HeatCapacity c_p = 1;
parameter SIunits.ThermalConductivity k=1;
parameter SIunits.Length L=10 "Domain Length";

//Temperature Array
SIunits.Temp_K T_array[n] (start=fill(300,n)) "Nodal Temperatures";
//variabes
Real x_array[n];
Real x;
Real T;   
protected

// Computed parameters
parameter SIunits.Length dx=L/n "Distance between nodes";
equation

// Loop over interior nodes
for i in 2:n-1 loop
x_array[i] = i*dx;
rho*c_p*der(T_array[i]) = k*(T_array[i+1]-2*T_array[i]+T_array[i-1])/dx^2;   
end for;

// Boundary Conditions
x_array[1] = 0;
x_array[n] = L;
 
T_array[1] = 1000;
T_array[n] = 300;

//array2time
x = array2time(x_array,time);
T = array2time(T_array,time);
end HeatTransfer;


simulate(HeatTransfer, method = "dassl", numberOfIntervals=100)


plotParametric(x,T)

Re: Partial Differential Equations in OM

Here is another thread on PDEs in this forum: https://www.openmodelica.org/index.php/ … pic?id=147

Re: Partial Differential Equations in OM

Hi everybody,

I made this GitHub repository to collect all the materials i could find the internet regarding solving partial differential equations in Modelica. please join me to push this matter a little bit forward:
https://github.com/Foadsf/ModelicaPDE

Edited by: foadsf - Aug-05-17 17:14:19

Re: Partial Differential Equations in OM

Hello guys,

Thank you for your help in advance.

I am new to Modelica and i am using Dymola Software.
I have a thermal power plant model that was built by another person and I am trying to extract the differential equations or the state space representation of this model.

I translated the model to FMU file and exported it to Simulink. The model worked fine and gave proper simulation but it is treated as a black box with some inputs and outputs only and i cannot read the state variables of the system.

i got the dsmodel.mof file but it is not possible to read the ODE from there since it is a very complex system and i cannot extract the right equations. 

Does anyone know how to get a clear representation of the differential equations of the model in Dymola ?

Firas

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