?? odeeul0.prg
字號:
Execute(GetConfig(1));
autoconfig(x__):={if(AskUserYesNo("There is an error in your main input configuration:"+chr(13)+chr(10)+x__+chr(13)+chr(10)+"Do you want to configure the main input automatically?")==0,{abort(x__);},
{
i:=0;
while({unknown[i]:=GetUserInput("Enter the "+numtos(i+1)+"th unknown function:");i:=i+1;asc(unknown[i-1])!=0},{});
if(i==1,{abort("You must enter at least one unknown function.");},{});
unknown[i-1]:=0;
i:=0;computeall:="";
while({valid(unknown[i])==-4},{
computeall:=computeall+"unknown["+numtos(i)+"]:="+chr(34)+unknown[i]+chr(34)+";"+chr(13)+chr(10)+unknown[i]+"'(t):={"+
GetUserInput("Enter the right hand side of the equation "+unknown[i]+"'(t)=...")+"};"+chr(13)+chr(10)+
unknown[i]+"_:="+GetUserInput("Enter the initial value for the unknown function "+unknown[i]+" :")+";"+chr(13)+chr(10);
i:=i+1;
});
computeall:=computeall+"t0:="+GetUserInput("Enter the initial time:")+";"+
chr(13)+chr(10)+"maxt:="+GetUserInput("Enter the time extent:")+";"+chr(13)+chr(10)+
"dt:="+GetUserInput("Enter the time step:")+";"+chr(13)+chr(10);
SetConfig(computeall);
Abort("The setup is complete."+chr(13)+chr(10)+"Use File/Execute to start again.");
});
};
if((valid(t0)!=-1)&&(valid(t0)!=-2),
{autoconfig("You must define the variable t0 as the initial time.");},{});
if((valid(dt)!=-1)&&(valid(dt)!=-2),
{autoconfig("You must define the variable dt as the step size.");},{});
if((valid(maxt)!=-1)&&(valid(maxt)!=-2),
{autoconfig("You must define the variable maxt as the maximum time.");},{});
if((valid(unknown[0])!=-4),
{autoconfig("You must define the vector unknown[ ] as the names of the unknown functions.");},{});
t0:=t0*1.0;dt:=dt*1.0;maxt:=maxt*1.0;
t:=t0;
i:=0;
while({valid(unknown[i])==-4},
{
if(((j:=valid(execute(unknown[i]+"_")))==-1)||(j==-2),
{
execute(unknown[i]+":=" +unknown[i]+ "_*1.0;" );
},
{
autoconfig("The initial value for "+unknown[i]+" gives a non-numeric value.");
});
i:=i+1;
});
computeall1:=(computeall2:=(computeall3:=(computeall4:="")));
i:=0;
while({valid(unknown[i])==-4},
{
if(valid(execute(unknown[i]+"'"))==-16,
{
if((valid(execute(execute(unknown[i]+"'")))==-1)||(valid(execute(execute(unknown[i]+"'")))==-2),
{
computeall1:=computeall1+"y_seg"+anytos("%ld",i)+":=dt*execute(" +unknown[i]+ "');";
computeall2:=computeall2+"y_seg"+numtos(i)+":=(y_seg"+anytos("%ld",i)+"+dt*execute(" +unknown[i]+ "'))/2.0;";
computeall3:=computeall3+unknown[i]+ ":=y_seg"+anytos("%ld",i)+"+(xn"+numtos(i)+":="+unknown[i]+ ");";
computeall4:=computeall4+unknown[i]+ ":=y_seg"+anytos("%ld",i)+"+xn"+numtos(i)+ ";";
},
{
autoconfig("The equation for "+unknown[i]+" gives a non-numeric value.");
});
},
{
if((valid(execute(unknown[i]+"'(t0)"))==-1)||(valid(execute(unknown[i]+"'(t0)"))==-2),
{
computeall1:=computeall1+"y_seg"+anytos("%ld",i)+":=dt*" +unknown[i]+ "'(t);";
computeall2:=computeall2+"y_seg"+numtos(i)+":=(y_seg"+anytos("%ld",i)+"+dt*" +unknown[i]+ "'(t))/2.0;";
computeall3:=computeall3+unknown[i]+ ":=y_seg"+anytos("%ld",i)+"+(xn"+numtos(i)+":="+unknown[i]+ ");";
computeall4:=computeall4+unknown[i]+ ":=y_seg"+anytos("%ld",i)+"+xn"+numtos(i)+ ";";
},
{
autoconfig("The equation for "+unknown[i]+" is not defined or gives a non-numeric value.");
});
});
i:=i+1;
});
j:=1;
computeall1:="{"+computeall1+computeall3+"t:=t+dt;"+computeall2+computeall4+"updateviews(0);j:=j+1;}";
computeall:=execute(computeall1);
ExecViewTemplates(1);
cont(mt):={maxt:=mt;while({t<=maxt},computeall);};
cont(maxt);
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -