- Index
- » Users
- » stefaneidelloth
- » Profile
Posts
Posts
Any update on this? Here is the link to PDElib (project seems to be death): https://www.modelica.org/libraries/PDELib/
Here is another thread on PDEs in this forum: https://www.openmodelica.org/index.php/ … pic?id=147
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)
Here is how it works:
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;
model test
//this model shows a work around to plot arrays in modelica
//define some arrays
constant Real V_array[:]={ 0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.55, 0.6};
constant Real J_array[:]={ -30, -29.8, -29.5, -29, -26, -15, 5, 30};
//define some variables that will hold the array data
Real V;
Real J;
equation
//transform array data to time data
V = array2time(V_array,time);
J = array2time(J_array,time);
end test;
simulate(test);
plotParametric(V,J)
plot(V)
plot(J)
Thank you for your reply. However, it does not give new information.
Anyway, I would still prever a solution that works inside OpenModelica. Maybe it is possible
to transform the array data at a certain time in a dummy variable?
V[x,t=1] = > V_dummy[t*],
J[x,t=1] = > J_dummy[t*],
plotParametric(V_dummy,J_dummy) ???
Ok, so I guess it is not possible in OpenModelica.
There is a Matlab-OpenModelica Interface to import the *.mat files:
http://www.mathworks.com/matlabcentral/ … -interface
However, it is quite old and does not work with the current version of OpenModelica.
If there is a solution that works with arrays and with the current version of OpenModelica, please let me know.
Hi together,
I work with arrays and would like to plot some simulation results. For example I have the voltage array V[x]:
V[10]:=1:10;
It represents the voltage as function of the space index x. Each local voltage V[x] depends on the time.
I also have a second array J[x]:
J[10]:=2:20;
How can i plot V[x] as function of J[x] for a specific time?
I would need something like
Vend[:] = val(V[:],1)
Jend[:] = val(J[:],1)
plotArray(Vend[:], Jend[:])
Sunny regards,
Stefan
ok, thanks a lot.
(I dont know if this is the right place for an improvement suggestion? Is there a wishlist/roadmap for OpenModelica?)
I am new to OpeModelica and would like to suggest arguments for the "help" command, like in Matlab or Octave, for the OMShell. This would also require an easy way to include help lines in a new model. In Matlab it works like this:
function test()
%This is the documentation for this user defined function.
%Further explanations
%This is not part of the documenation
message = "hello world"
end
>help test
> %This is the documentation for this user defined function.
>%Further explanations
Is there something similar in OpenModelica?
- Index
- » Users
- » stefaneidelloth
- » Profile