manon22lr

45 Reputation

One Badge

0 years, 55 days

MaplePrimes Activity


These are replies submitted by manon22lr

@acer 

I ran the .mw file you attached to your answer (just changed the path to my data file). I have Maple 2020 and DirectSearch2.

@acer 

Thanks for your help. I don't understand why but your code is not working when I run it. I still get the same error

Error, (in DirectSearch:-DataFit) Vector (Matrix) with values of independent or dependent variables is missing

@acer 

Thank you for your help !

@acer 

It's exactly what I wanted to achieve ! Thank you for your help. I've been using Maple for only a month so I wouldn't have found this solution.

Thanks again

@acer 

Oh yes sorry... tensdBE[1,1] is the first componant of tensdBe which is

tensdBe:=diff(tensBe,t);

 

@Carl Love thank you for your answer

Let's say that "lambdaTrig" is a sinus function and the experiemental data PK1Expe are in this file  donnees_cycles_sin_lejeunes.xlsx.

The code is then

data:=ExcelTools:-Import("D:/Maple/donnees_cycles_sin_lejeunes.xlsx") : 
PK1Expe:=Column(data,1):
with(LinearAlgebra):
fHz:=3: #fréquence
lambdaS:=0.5:
lambdaD:=0.3:
lambdaTrig:= piecewise(t < 1/fHz, 1+lambdaS*t*fHz, t >= 1/fHz, 1+lambdaS+lambdaD*sin((2*Pi*(t-1/fHz)*fHz))):

with(LinearAlgebra):
tensF:=Matrix([[lambdaTrig,0,0],[0,1/sqrt(lambdaTrig),0],[0,0,1/sqrt(lambdaTrig)]]):
tensdF:=diff(tensF,t):
tensFDev:=tensF-(1/3)*Trace(tensF)*Matrix(3,shape=identity):
tensB:=Multiply(tensF,Transpose(tensF)):
tensL:=Multiply(tensdF,MatrixInverse(tensF)):
tensD:=(1/2)*(tensL+Transpose(tensL)):
tensBe:=Matrix([[Be11(t),0,0],[0,1/sqrt(Be11(t)),0],[0,0,1/sqrt(Be11(t))]]):
tensBeDev:=tensBe-(1/3)*Trace(tensBe)*Matrix(3,shape=identity):

ode:=tensdBe[1,1]=-(2/3)*tensBe[1,1]*Trace(tensD)+Multiply(tensL[1,1],tensBe[1,1])+Multiply(tensBe[1,1],Transpose(tensL[1,1]))-(2/eta)*a*Multiply(tensBeDev[1,1],tensBe[1,1]): ivp:=[ode,Be11(0)=1]: 
ode_sol:=dsolve(ivp,numeric,parameters=[a,eta]); 
ode_sol(parameters=[a=1,eta=0.1]); 
Be11Num:=proc(aValue,etaValue) global ode_sol,a,eta,t; ode_sol('parameters'=[a=aValue,eta=etaValue]); end proc;

tensTemp1:=2*C1*tensB+4*C2*(Trace(tensB)-3)*tensB+6*C3*(Trace(tensB)-3)*tensB-2*C4*MatrixInverse(tensB):
tensTemp1Dev:=tensTemp1-(1/3)*Trace(tensTemp1)*Matrix(3,shape=identity):
tensBe:=Matrix([[Be11Num,0,0],[0,1/sqrt(Be11Num),0],[0,0,1/sqrt(Be11Num)]]):
tensTemp2Dev:=2*a*tensBe-(1/3)*Trace(2*a*tensBe)*~Matrix(3,shape=identity):
sigma:=tensTemp1Dev+tensTemp2Dev-p*~Matrix(3,shape=identity):
p:=sigma[2,2]+p: 
sigma:=tensTemp1Dev+tensTemp2Dev-p*~Matrix(3,shape=identity): 
PK:=sigma.Transpose(MatrixInverse(tensF)):
PK:=PK[1,1]: #expression  to fit

vectorT:=[seq(i,i=0..13/3,0.01)]:
vectorT:=Vector(vectorT):
NonlinearFit(PK,vectorT,PK1Expe,t,output=[parametervalues,residualsumofsquares]);

And the output of NonlinearFit is

[[Be11Num = 0.999909116489001, C1 = 0.165178056596736, C2 = -3806.78574283673, C3 = 2537.89711168611, a = 1824.85278527722], 32.16328290]

And what I would need is the value of Be11Num(t) with the right set of parameters a and eta to fit my data.

 

 

@Thomas Richard thank you for your help

Thank you for your quick answer.

So yes this -remove_RootOf works fine to get a more "normal" solution.

From dsolve, is it not possible to get a solution in the form y(t)=something depending on t, and the parameters a and eta. And then assign a and eta a value, and compute y(t) for each t ?

@acer 

Thank you for taking the time to answer my question.

It worked only when I don't use the output=listprocedure option and write eval(y(t),lambdaE(tCompute[i]))  instead.

Many thanks for your help !

Manon

Page 1 of 1