I'm trying to use OpenModelica to numerically solve a very simple PDE du/dx=du/dt with boundary condition u(0,t)=t^2 and u_x(0,t)=0. I have written the code below:
model pdetest_1
parameter Real L=1;
parameter Integer N=100;
parameter Real dx=L/(N-1);
parameter Real[N] x=array(i*dx for i in 0:N-1);
Real u[N],ux[N];
initial equation
for i in 1:N loop
u[i]=0;
end for;
equation
u[1]=(time)^2;
ux[1]=0;
for i in 2:N loop
u[i]=u[i-1]+dx*ux[i-1];
der(u[i])=ux[i];
end for;
end pdetest_1;
It does compile however it does not finish the simulation quitting with the error below:
Blocstdout | OMEditInfo |
C:/Users/.../AppData/Local/Temp/OpenModelica/OMEdit/pdetest_1.exe -port=50450 -logFormat=xmltcp -override=startTime=0,stopTime=1,stepSize=0.002,tolerance=1e-6,solver=dassl,outputFormat=mat,variableFilter=.* -r=pdetest_1_res.mat -jacobian=coloredNumerical -w -lv=LOG_STATS
kquote LOG_INIT | error |The initialization problem is inconsistent due to the following equation: 0 != 0.000204061 = u[4]
stdout | warning |Error in initialization. Storing results and exiting.
stdout | error |
Use -lv=LOG_INIT -w for more information.Simulation process failed. Exited with code -1.
I would appreciate if you could help me know what is the problem and how I can solve it?