Physikuss

0 Reputation

2 Badges

14 years, 23 days

MaplePrimes Activity


These are replies submitted by Physikuss

Hi, I just changed the procedure as follows:

ans:=proc(p1,p2) solL(parameters=[lambda[0]=p1,T[m]=p2]); rhs(solL(3600)[2]); end proc;

It works so far, but when calling the Fit

FitParams:=Statistics:-NonlinearFit(ans(test1,test2), TVector, LVector, initialvalues=<150e-9>, 
output=parametervalues);

I get another error message:

Error, (in dsolve/numeric/process_parameters) parameter values must evaluate to numeric, got lambda[0] = test1

I just prepared a file which contains the main calculation including the fit command

 

variables
R[s]:=5.7e17:
N[A]:=6e23:
V[m]:=13.63e-6:
#lambda[s]:=500e-9:
#lambda[w]:=500e-9:
#lambda[0]:=250e-9:
alpha:=7*Pi/180:
r[w]:=100e-9:
R[w]:=sin(alpha)*R[s]:
J[sw]:=-lambda[s]*R[s]*BesselK(1,r[w]/lambda[s])/BesselK(0,r[w]/lambda[s]):
Omega:=V[m]/N[A]:
T[0]:=450+273:
#T[m]:=450+273:
N[i0]:=5e12:
G[s]:=10:
F[s]:=10:
N[w]:=1e10:

erase variables
R[s]:='R[s]':
N[A]:='N[A]':
V[m]:='V[m]':
#lambda[s]:='lambda[s]':
#lambda[w]:='lambda[w]':
lambda[0]:='lambda[0]':
alpha:='alpha':
r[w]:='r[w]':
R[w]:='R[w]':
J[sw]:='J[sw]':
Omega:='Omega':
T[0]:='T[0]':
T[m]:='T[m]':
N[i0]:='N[i0]':
G[s]:='G[s]':
F[s]:='F[s]':
N[w]:='N[w]':

model
lambda[s] := 1/sqrt(2*Pi*N[w]+2*Pi*N[i0]*exp(2*F[s]*(T[0]/T[m]-1))+exp(-2*G[s]*(T[0]/T[m]-1))/lambda[0]^2):
lambda[w]:=lambda[0]*exp(G[s]*(T[0]/T[m]-1)):
J[sw] := -R[s]*lambda[s]*BesselK(1, r[w]/lambda[s])/BesselK(0, r[w]/lambda[s]):
growth := Diff(L,t) = Omega*(2*R[w]*lambda[w]*sinh(L/lambda[w])-2*J[sw]*cosh(0)+R[d]*cosh(L/lambda[w])*r[w])/(cosh(L/lambda[w])*r[w]):

differential equation
Lpde:=subs(L=L(t),subs({R[w]=sin(alpha)*R[s],J[sw]=-lambda[s]*R[s]*BesselK(1,r[w]/lambda[s])/BesselK(0,r[w]/lambda[s]),R[d]=R[s],Omega=V[m]/N[A]},growth)):
ICS:=L(0)=0:

solving Lpde numerically
solL:=dsolve({Lpde,ICS}, numeric, method=rkf45, parameters=[lambda[0],T[m]]):

#procedure with parameters from dsolve as arguments
ans:=proc(p1,p2) solL(parameters=[lambda[0]=p1,T[m]=p2]); rhs(solL(3600)[2]); end proc:

experimental data
TVector:=Vector([623,643,683,703,723,743,763,783]):
LVector:=Vector([179e-9,200e-9,221e-9,233e-9,228e-9,222e-9,204e-9,202e-9]):

nonlinear fit
FitParams:=Statistics:-NonlinearFit(ans(test1,test2), TVector, LVector, initialvalues=<150e-9>, output=parametervalues);

Error, (in dsolve/numeric/process_parameters) parameter values must evaluate to numeric, got lambda[0] = test1

 

 

 

Download TryToFit.mw

The problem is, I need to use a paramenter from dsolve as the independent variable in the fit.

Hi, I just changed the procedure as follows:

ans:=proc(p1,p2) solL(parameters=[lambda[0]=p1,T[m]=p2]); rhs(solL(3600)[2]); end proc;

It works so far, but when calling the Fit

FitParams:=Statistics:-NonlinearFit(ans(test1,test2), TVector, LVector, initialvalues=<150e-9>, 
output=parametervalues);

I get another error message:

Error, (in dsolve/numeric/process_parameters) parameter values must evaluate to numeric, got lambda[0] = test1

I just prepared a file which contains the main calculation including the fit command

 

variables
R[s]:=5.7e17:
N[A]:=6e23:
V[m]:=13.63e-6:
#lambda[s]:=500e-9:
#lambda[w]:=500e-9:
#lambda[0]:=250e-9:
alpha:=7*Pi/180:
r[w]:=100e-9:
R[w]:=sin(alpha)*R[s]:
J[sw]:=-lambda[s]*R[s]*BesselK(1,r[w]/lambda[s])/BesselK(0,r[w]/lambda[s]):
Omega:=V[m]/N[A]:
T[0]:=450+273:
#T[m]:=450+273:
N[i0]:=5e12:
G[s]:=10:
F[s]:=10:
N[w]:=1e10:

erase variables
R[s]:='R[s]':
N[A]:='N[A]':
V[m]:='V[m]':
#lambda[s]:='lambda[s]':
#lambda[w]:='lambda[w]':
lambda[0]:='lambda[0]':
alpha:='alpha':
r[w]:='r[w]':
R[w]:='R[w]':
J[sw]:='J[sw]':
Omega:='Omega':
T[0]:='T[0]':
T[m]:='T[m]':
N[i0]:='N[i0]':
G[s]:='G[s]':
F[s]:='F[s]':
N[w]:='N[w]':

model
lambda[s] := 1/sqrt(2*Pi*N[w]+2*Pi*N[i0]*exp(2*F[s]*(T[0]/T[m]-1))+exp(-2*G[s]*(T[0]/T[m]-1))/lambda[0]^2):
lambda[w]:=lambda[0]*exp(G[s]*(T[0]/T[m]-1)):
J[sw] := -R[s]*lambda[s]*BesselK(1, r[w]/lambda[s])/BesselK(0, r[w]/lambda[s]):
growth := Diff(L,t) = Omega*(2*R[w]*lambda[w]*sinh(L/lambda[w])-2*J[sw]*cosh(0)+R[d]*cosh(L/lambda[w])*r[w])/(cosh(L/lambda[w])*r[w]):

differential equation
Lpde:=subs(L=L(t),subs({R[w]=sin(alpha)*R[s],J[sw]=-lambda[s]*R[s]*BesselK(1,r[w]/lambda[s])/BesselK(0,r[w]/lambda[s]),R[d]=R[s],Omega=V[m]/N[A]},growth)):
ICS:=L(0)=0:

solving Lpde numerically
solL:=dsolve({Lpde,ICS}, numeric, method=rkf45, parameters=[lambda[0],T[m]]):

#procedure with parameters from dsolve as arguments
ans:=proc(p1,p2) solL(parameters=[lambda[0]=p1,T[m]=p2]); rhs(solL(3600)[2]); end proc:

experimental data
TVector:=Vector([623,643,683,703,723,743,763,783]):
LVector:=Vector([179e-9,200e-9,221e-9,233e-9,228e-9,222e-9,204e-9,202e-9]):

nonlinear fit
FitParams:=Statistics:-NonlinearFit(ans(test1,test2), TVector, LVector, initialvalues=<150e-9>, output=parametervalues);

Error, (in dsolve/numeric/process_parameters) parameter values must evaluate to numeric, got lambda[0] = test1

 

 

 

Download TryToFit.mw

The problem is, I need to use a paramenter from dsolve as the independent variable in the fit.

Page 1 of 1