manon22lr

45 Reputation

One Badge

0 years, 55 days

MaplePrimes Activity


These are questions asked by manon22lr

Hello,

I'm trying to fit experimental data to a model in which a variable is the result of an equation.

In a procedure I solved the equation and found lambda22 for each of the data lambda11 I have. It depends on a a parameter I need to identify to fit the data to the model.

But then when I use DataFit from DirectSearch package, I get this error :

Is it impossible to specify more than one independant variable ? Or is it a problem coming from the procedure ?

Thanks in advance,

Manon

data.xlsx

restart;

data:=ExcelTools:-Import("D:/data.xlsx") : # importer les donnees
with(LinearAlgebra): 
lambdaX:=Column(data,1): 
PK1X:=Column(data,2):


tensF:=Matrix([[lambda11,0,0],[0,lambda22,0],[0,0,lambda22]]):
tensFbar:=Matrix([[(lambda11/lambda22)^(2/3),0,0],[0,1/sqrt((lambda11/lambda22)^(2/3)),0],[0,0,1/sqrt((lambda11/lambda22)^(2/3))]]):
tensBbar:=Multiply(tensFbar,Transpose(tensFbar)):

kappa:=100:
tensPK:=Multiply(Transpose(MatrixInverse(tensF)),(2/Determinant(tensF))*a*(tensBbar-(1/3)*Trace(tensBbar)*Matrix(3,shape=identity))+kappa*(Determinant(tensF)-1)*Matrix(3,shape=identity)):
PK1:=tensPK[1,1]:
eq:=0=tensPK[2,2]:


lambda22sol:=proc(aValue) 
   global __old_a;
   local res, i, eq1, sol1, lambda22Est;
   if not [aValue]::list(numeric) then
      return 'procname'(args);
   end if;
   lambda22Est:=Vector(1..RowDimension(lambdaX)):
   eq1:=Array(1..RowDimension(lambdaX)):
   if __old_a<>aValue then
      __old_a:= aValue;
     for i from 1 to RowDimension(lambdaX) do
     	eq1[i]:=eval(eq,[a=aValue,lambda11=lambdaX[i]]):
		sol1:=solve(eq1[i], lambda22);
		lambda22Est[i]:=sol1[1]:
	end do:
	res:=lambda22Est;
   end if;
end proc:

matrix1:=<lambdaX|lambda22sol(0.9)|PK1X>;
DS1:=CodeTools:-Usage(
        DirectSearch:-DataFit(PK1,matrix1,[lambda11,lambda22]));
res2:=eval(PK1,DS1[2]):

 

Hello,

I'm writing a script that solves a system of equations. I have 2 unknows that I seem to get when using "explicit" et "allvalues". The result I get from "allvalues" is in this form. My question is : how can I get just the result, without the "lambda22=" (other than copy/paste of course ;))?

lambda22 = sqrt(10)*sqrt(lambda11*(pi*lambda11 + 90))/(30*lambda11)

My code is

kappa:=30:
tensF:=Matrix([[lambda11,0,0],[0,lambda22,0],[0,0,lambda22]]):
tensFbar:=Matrix([[lambda11bar,0,0],[0,1/sqrt(lambda11bar),0],[0,0,1/sqrt(lambda11bar)]]):
tensBbar:=Multiply(tensFbar,Transpose(tensFbar)):

tensPK:=Matrix([[pi,0,0],[0,0,0],[0,0,0]]):
tensPK1:=Multiply(Transpose(MatrixInverse(tensF)),(2/Determinant(tensF))*a*(tensBbar-(1/3)*Trace(tensBbar)*Matrix(3,shape=identity))+kappa*(Determinant(tensF)-1)*Matrix(3,shape=identity)):
eq1:=tensPK[1,1]=tensPK1[1,1]:
eq2:=tensPK[2,2]=tensPK1[2,2]:
sys:={eq1,eq2}:
sol1:=solve( sys, {lambda11bar,lambda22},explicit):


allvalues(sol1[1][1]);
allvalues(sol1[1][2]);

This should be something easy to get but I don't find the method anywhere.

Many thanks in advance if you know how to do this,

Manon

Hello,

I would like to know if it is possible to Fit data to an expression using NonlinearFit, but in this expression there is a variable that is the result of dsolve and the contains parameters I need to identify.

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))]]):
tensdBe:=diff(tensBe,t):
tensBeDev:=tensBe-(1/3)*Trace(tensBe)*Matrix(3,shape=identity):

Above are the tensors I need in the expression.

Then there is the equation to solve. I tried something with "proc", I found on Maple Help Page.

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;

Then I built the expression I need to fit :

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*G*tensBe-(1/3)*Trace(2*G*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

Then I tried to fit

NonlinearFit(PK,t1Expe,PK1Expe,t,output=[parametervalues,residualsumofsquares]);

The problem is that the result is

[[Be11Num = 1.00001503587671, C1 = 0.588252936860393, C2 = 6091.63136742778, C3 = -4061.11176413018, C4 = -0.494824008942008, G = 1409.06089189383], 17.90514021]

It's computing the solution Be11 but I can't get the value of the parameters a and eta. Moreover Be11 is depending on t, so it seems I only get the last value.

What do you think, is it possible to do what I just explained ?

Thnak you in advance,

Manon

Hello,

I would like to solve this equation and keep the parameters a and eta unknown and assign them a value later on. Is it possible ?

I know I can solve this equation numerically, it works, but I want to change the parameters to fit experimental data.

I tried this :

ode:=diff(y(t),t)=-(4/3)*(a/eta)*(y(t)^3+1):
lambdaE:=dsolve({ode,y(0)=1},y(t),explicit);

But the solution appears with RootOf expression and I can't get a numerical solution afterwards.

lambdaE := y(t) = RootOf(6*eta*sqrt(3)*arctan(((2*_Z - 1)*sqrt(3))/3) - eta*sqrt(3)*Pi - 3*eta*ln(_Z^2 - _Z + 1) + 6*eta*ln(_Z + 1) - 6*eta*ln(2) + 24*t*a)

I tried some things from forums but nothing works.

Do you have any leads on how to do it please ?

Thank you in advance

Manon

Hello,

I'm new to Maple and I'm struggling with dsolve output.

I solve this equation
 

ode:=diff(y(t),t)=-(4/3)*(a/eta)*(y(t)^3+1):
lambdaE:=dsolve({ode,y(0)=1},y(t),numeric,method=classical[rk4],parameters=[a,eta],output=listprocedure):
lambdaE(parameters=[theta[5,1],eta0]):

tCompute:=20*(lambda-~1)/(50/60): #vector with times I need 
# lambda is a 371 lines column vector

Then I need the value of the solution at each time to compute components of a matrix

J:=Matrix(371,5):
for i from 1 to 371 do
	J[i,1]:=2*(lambda[i]-1/lambda[i]^2);
	J[i,2]:=4*(lambda[i]^2-2/lambda[i]-3)*(lambda[i]-1/lambda[i]^2);
	J[i,3]:=6*(lambda[i]^2-2/lambda[i]-3)^2*(lambda[i]-1/lambda[i]^2);
	J[i,4]:=2*(1-1/lambda[i]^3);
	J[i,5]:=2*(lambdaE(tCompute[i])^2/lambda[i]-(1/lambdaE(tCompute[i])*lambda[i])); #here is where I need the value
end do;

However the output in the 5th column of J is something with y(t) and t inside

1.997498088*[t = 0.0300605520000000, y(t) = 0.999829465489350]^2 - 2.002505046/([t = 0.0300605520000000, y(t) = 0.999829465489350])

Would you have a solution to get only the numerical value ?

Thanks a lot in advance

Manon

Page 1 of 1