I'm working with parabolic PDE's mixed with algebraic equation plus all these equation are coupled. I used Euler Method (Dassl is too slow) and big tolerance(for fast simulation) and recive error (for both types) in OM(1.9.1)(" residualFcn[some number]").The problem is that solver can't solve nonlinear system (mathematically, system is correct ). First question is what type of method use Euler method of integration in OM(explicit or implicit or Crank-Nicholson..or...)? So i tried to solve it numerically(explicit Euler Method (in code below "new[N]") (maybe the problem can be CFL condition.), but i have the problem (sample reconstruction for specific sample time). So, second question refers to reproducing values for specific sample time?! In code below there is array "a[3]". Idea is for every "ts(sample time)" reconstruct values in 3 nodes. How can this be done? How can i pass from algorithm section current values(i.e. for nodes) to equation section? I have all values in .txt file and i used Matlab to plot them, but i don't know how to pass it i.e. in "equation" section, or some another way. Same problem is for "new[N]", for specific sample time,plot function of nodes (N).
One more thing, if delta(t)/(delta(x))^2 >= 0.5 (delta(t) define the user, and refers to equation section, delta(x) is as in code below and spatial discretization is used in equation section (classical feedforward method)), is numerical stability satisfied? Same example but for algorithm section? Regards
Here is code:
model Euler1D
import Modelica.Utilities.*;
parameter Integer N=10; //50
parameter Real Lp=1e-6;
parameter Real deltax=1/(N-1)*Lp;
Real a[3];
Real old[N];
Real new[N];
Real b;
equation
a[1]=if
(time>5) then 0 else time+5;
a[2]=time;
a[3]=2;
when
(sample(0,1)) then
d=b;
end when;
algorithm
// IN t=ts;
when (sample(0,1)) then
for i in 1:2 loop
b:=a[i];
Streams.print(String(time)+" "+String(a[i])+ " "+String(b), "C:/Some_Path/text.txt");
end for;
end when;
// Another problem
old[1]:=10;
old [N]:=0;
new[1]:=10;
new [N]:=0;
// Boundary
for i in 2:N-1 loop
old [i]:=10;
new[i]:=10;
end for;
for dx in deltax:deltax:Lp-deltax loop // spatial discretization
for i in 2:N-1 loop
(new[i]):=(old[i]+0.5*(old[i + 1] +old[i-1]- 2*old[i]));
//def:=def+abs(new[i]-old[i]);
end for;
for i in 2:N-1 loop
old[i]:=new[i]; // switch the values
end for;
for i in 1:N loop
Streams.print(String(time)+" "+ String(new[2]), "C:/Some_Path/Anel_Nodes.txt");
end for;
annotation (uses(Modelica(version="3.2")));
end Euler1D;