?? oderk0.prg
字號:
Execute(GetConfig(1));
CR := Chr(13) + Chr(10);
PP := Chr(34);
autoconfig(x__):=
{
If(
AskUserYesNo("There is an error in your main input "+
"configuration:"+CR+x__+CR+
"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)+"]:="+
PP+unknown[i]+PP+";"+CR+unknown[i]+"'(t):={"+
GetUserInput("Enter the right hand side of the "+
"equation "+unknown[i]+"'(t)=...")+"};"+CR+
unknown[i]+"_:="+
GetUserInput("Enter the initial value for the "+
"unknown function "+unknown[i]+" :")+";"+
CR;
i:=i+1;
}
);
computeall:=computeall+"t0:="+
GetUserInput("Enter the initial time:")+";"+CR+"maxt:="+
GetUserInput("Enter the time extent:")+";"+CR+"dt:="+
GetUserInput("Enter the time step:")+";"+CR;
SetConfig(computeall);
Abort("The setup is complete."+CR+
"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;
dtper2:=(dt/2)*1.0;
dtper6:=(dt/6)*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;
}
);
computek1:=(computek2:=(computek3:=(computek4:="")));
computestep1:=(computestep2:=(computestep3:=(computes:="")));
computestep:="";
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),
{
computek1 := computek1+"k1_"+Anytos("%ld",i)+
":=execute("+unknown[i]+"');";
computestep1 := computestep1 + unknown[i]+ ":=dtper2*k1_"+
Anytos("%ld",i)+"+(xn"+numtos(i)+":="+unknown[i]+ ");";
computek2 := computek2+"k2_"+Anytos("%ld",i)+
":=execute("+unknown[i]+"');";
computestep2 := computestep2 + unknown[i]+ ":=dtper2*k2_"+
Anytos("%ld",i)+"+xn;";
computek3 := computek3+"k3_"+Anytos("%ld",i)+
":=execute("+unknown[i]+"');";
computestep3 := computestep3 + unknown[i]+ ":=dt*k3_"+
Anytos("%ld",i)+"+xn;";
computek4 := computek4+"k4_"+Anytos("%ld",i)+
":=execute("+unknown[i]+"');";
computes := computes+"s_"+Anytos("%ld",i)+":=dtper6*(k1_"+
Anytos("%ld",i)+"+k2_"+Anytos("%ld",i)+"+k2_"+
Anytos("%ld",i)+"+k3_"+Anytos("%ld",i)+"+k3_"+
Anytos("%ld",i)+"+k4_"+Anytos("%ld",i)+");";
computestep := computestep + unknown[i]+":=s_"+
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),
{
computek1 := computek1+"k1_"+
Anytos("%ld",i)+":="+unknown[i]+"'(t);";
computestep1 := computestep1 + unknown[i]+ ":=dtper2*k1_"+
Anytos("%ld",i)+"+(xn"+numtos(i)+":="+unknown[i]+ ");";
computek2 := computek2+"k2_"+
Anytos("%ld",i)+":="+unknown[i]+"'(t);";
computestep2 := computestep2 + unknown[i]+ ":=dtper2*k2_"+
Anytos("%ld",i)+"+xn"+numtos(i)+";";
computek3 := computek3+"k3_"+
Anytos("%ld",i)+":="+unknown[i]+"'(t);";
computestep3 := computestep3 + unknown[i]+ ":=dt*k3_"+
Anytos("%ld",i)+"+xn"+numtos(i)+";";
computek4 := computek4+"k4_"+
Anytos("%ld",i)+":="+unknown[i]+"'(t);";
computes := computes+"s_"+Anytos("%ld",i)+":=dtper6*(k1_"+
Anytos("%ld",i)+"+k2_"+Anytos("%ld",i)+"+k2_"+
Anytos("%ld",i)+"+k3_"+Anytos("%ld",i)+"+k3_"+
Anytos("%ld",i)+"+k4_"+Anytos("%ld",i)+");";
computestep := computestep + unknown[i]+":=s_"+
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:="{"+computek1+computestep1+"t:=t+dtper2;"+computek2+
computestep2+computek3+computestep3+"t:=t+dtper2;"+computek4+computes+
computestep+"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 + -