Items tagged with ode ode Tagged Items Feed

Dear collegues

I wrote the following code

 


restart:
Digits := 15;
a[k]:=0;
b[k]:=7.47;
a[mu]:=39.11;
b[mu]:=533.9;
mu[bf]:=9.93/10000;
k[bf]:=0.597;
ro[p]:=3880 ;
ro[bf]:= 998.2;
c[p]:= 773;
c[bf]:= 4182;
#mu[bf]:=1;
Gr[phi]:=0; Gr[T]:=0;
#dp:=0.1;
Ree:=1;
Pr:=1;
Nbt:=cc*NBTT+(1-cc^2)*6;

#######################
slip:=0.1;         ####
NBTT:=2;           ####
lambda:=0.1;       ####
phi_avg:=0.02;    ####
#######################


eq1:=diff( (1+a[mu]*phi(eta)+b[mu]*phi(eta)^2)*diff(u(eta),eta),eta)+dp/mu[bf]+Gr[T]*T(eta)-Gr[phi]*phi(eta);
eq2:=diff((1+a[k]*phi(eta)+b[k]*phi(eta)^2)*diff(T(eta),eta),eta)+lambda*T(eta)/k[bf];
eq3:=diff(phi(eta),eta)+1/Nbt*diff(T(eta),eta);
Q:=proc(pp2,fi0) local res,F0,F1,F2,a,INT0,INT10;
global Q1,Q2;
print(pp2,fi0);
if not type([pp2,fi0],list(numeric)) then return 'procname(_passed)' end if:
res := dsolve({subs(dp=pp2,eq1)=0,eq2=0,eq3=0,u(0)=slip*D(u)(0),u(1)=-slip*D(u)(1),D(T)(0)=0,D(T)(1)=1,phi(0)=fi0}, numeric,output=listprocedure,continuation=cc);
F0,F1,F2:=op(subs(res,[u(eta),phi(eta),T(eta)])):
INT0:=evalf(Int(F0(eta),eta=0..1));
INT10:=evalf(Int(F0(eta)*F1(eta),eta=0..1));
a[1]:=evalf(Int(F0(eta),eta=0..1))-Ree*Pr;;
a[2]:=INT10/INT0-phi_avg;
Q1(_passed):=a[1];
Q2(_passed):=a[2];
if type(procname,indexed) then a[op(procname)] else a[1],a[2] end if
end proc;
Q1:=proc(pp2,fi0) Q[1](_passed) end proc;
Q2:=proc(pp2,fi0) Q[2](_passed) end proc;
Optimization:-LSSolve([Q1,Q2],initialpoint=[0.3,0.0007]);




se:=%[2];
res2 := dsolve({subs(dp=se[1],eq1)=0,eq2=0,eq3=0,u(0)=slip*D(u)(0),u(1)=-slip*D(u)(1),D(T)(0)=0,D(T)(1)=1,phi(0)=se[2]}, numeric,output=listprocedure,continuation=cc);
G0,G1,G2:=op(subs(res2,[u(eta),phi(eta),T(eta)])):
TTb:=evalf(Int(G0(eta)*G2(eta)*(G1(eta)*ro[p]*c[p]+(1-G1(eta))*ro[bf]*c[bf] ),eta=0..1))/evalf(Int(G0(eta)*(G1(eta)*ro[p]*c[p]+(1-G1(eta))*ro[bf]*c[bf] ),eta=0..1));
with(plots):
odeplot(res2,[[eta,phi(eta)/phi_avg]],0..1);
odeplot(res2,[[eta,T(eta)/TTb]],0..1);
odeplot(res2,[[eta,u(eta)/(Ree*Pr)]],0..1);

res2(1);
Nuu:=(1/TTb);
1/((1+a[k]*G1(1)+b[k]*G1(1)^2)/(1+a[k]*phi_avg+b[k]*phi_avg^2));
(1/TTb)*(((1+a[k]*G1(1)+b[k]*G1(1)^2)/(1+a[k]*phi_avg+b[k]*phi_avg^2)));
>

I want to run the code for the value of NBTT in the range of 0.2 to 10. this code gave the results in the range of 4-10 easily. So, I used the continuation which improve the range of the results between 2-10. However, I coudnt gave the results when 0.2<NBTT<2. Would you please help me in this situation.

Also, It is to be said that the values of phi should be positive. in some ranges, I can see that phi(1) is negative. Can I place a condition in which the values phi restricted to be positive.

Thanks for your attentions in advance

Amir

Dear all;

Than you for help.

how  many steps are required to achieve a error of 1.e-3 in the numerical value of y(1).

Here The 3 -step procedure  Range Kutta Method.

## Exact  solution  

### We will modifty N ( number of steps to get error =10^(-3). )

 

## Procedure Range Kutta

> RK3 := proc (f, a, b, y0, N)

local x, y, n, h, k, vectRK3;

y := Array(0 .. N);

x := Array(0 .. N);

h := evalf(b-a)/N;

x[0] := a; y[0] := 1;

for n from 0 to N-1 do

x[n+1] := a+(n+1)*h;

k[1] := f(x[n], y[n]);

k[2] := f(x[n]+(1/2)*h, y[n]+(1/2)*h*k[1]);

k[3] := f(x[n]+h, y[n]+h*(-k[1]+2*k[2]));

y[n+1] := y[n]+(1/6)*h*(k[1]+4*k[2]+k[3])

end do;

[seq([x[n], y[n]], n = 0 .. N)]; y[1];

end proc;

## Now  we compute the error between y(1) and exact  solution for different value of  N

### I have a problem in this part


 errorRk3 := array(1 .. 29);
 for N from  2 to 30 do

errorrRk3[N] := abs(eval(rhs(res), x = 1)-RK3((x,y)->-y,0,1,N));

if errorrRk3[N] =10^{-3} end ;
end  do ;

 

 

ode plot help??...

March 12 2014 J4James 175

restart:

Eq1:=diff(f(x),x)=1;

f:=1:

plot(1,x=0..10);

cs:=(f)(0)=0;

p:=dsolve({Eq1,cs},numeric);

odeplot(p, [x,diff(f(x),x)], 0..10);

why I cannot get a plot diff(f(x),x) like this?

 

whats going on here?

 

 

 

Dear all;

Please Have some one an idea to transform or convert 2nd order ODE to system of First ODE ( of course using maple).

Thanks

 

Hi,

I wrote the following code which is properly run

 


restart:

# parametrs

MUR:=(1-phi)^2.5:
RhoUR:=(1-phi+phi*rho[p]/rho[f]):
RhoCPR:=(1-phi+phi*rhocp[p]/rhocp[f]):
BetaUR:=(phi*rho[p]*beta[p]+(1-phi)*rho[f]*beta[f])/(RhoUR*rho[f])/beta[f]:

dqu3:=diff(h(x),x$1)-RhoUR*BetaUR*T(x);
dqu2:=5*diff(T(x),x$2)+k[f]/k[nf]*Pr*RhoCPR*f(x)*diff(T(x),x$1);
dqu1:=5/(MUR)*diff(f(x),x$3)
+ 2*(diff(h(x),x$1)*x-h(x))
+RhoUR*(3*f(x)*diff(f(x),x$2)-diff(f(x),x$1)^2);
rho[f]:=998.2: cp[f]:=4182: k[f]:=0.597:   beta[f]:= 2.066/10000:
rho[p]:=3380: cp[p]:=773: k[p]:=36:   beta[p]:= 8.4/1000000:

k[nf]:=((k[p]+2*k[f])-2*phi*(k[f]-k[p]))/((k[p]+2*k[f])+phi*(k[f]-k[p])):
rhocp[nf]:=rho[p]*cp[p]*phi+rho[f]*cp[f]*(1-phi):
rhocp[p]:=rho[p]*cp[p]:
rhocp[f]:=rho[f]*cp[f]:

phi:=0.00:
binfinitive:=6: Pr:=7: lambda:=0:


with(plots):
pppe:=dsolve( {dqu1=0,dqu2=0,dqu3=0,T(0)=1,T(binfinitive)=0,f(0)=0,D(f)(0)=lambda,D(f)(binfinitive)=0,h(binfinitive)=0}, numeric );
-pppe(0);
print(odeplot(pppe,[x,diff(f(x),x)],0..binfinitive,color=black,numpoints=400));
print(odeplot(pppe,[[x,diff(f(x),x)]],0..binfinitive,color=black,numpoints=400));
print(odeplot(pppe,[[x,T(x)]],0..binfinitive,color=black,numpoints=400));


However, in some range of parameters, I must increase the value of binfinitive (for example binfinitive=50). however, my code is doesnt converge for higher values of 10 (at most). Can anyone change this algorithm in a way that it insensitive to the value of binfinitive?

Many thanks for your attention in advance

 

Amir

Is it possible to describe billiards in the unit square (see http://en.wikipedia.org/wiki/Dynamical_billiards for info) in terms of events and if? For example, let the dynamical system
{x''(t)=0,y''(t)=0, x(0)=0.5, x'(0)=0.2, y(0)=0.5, y'(0)= sqrt(3)/5}
be given, where the trajectory [x(t), y(t)] satisfies the usual laws of reflection http://en.wikipedia.org/wiki/Reflection_%28physics%29 when reaching the boundary {x=0}, {x=1}, {y=0}, {y=1}. The same question about billiards in the unit disk.

Dear all

Is there any one can help me to find  the Maple code to solve ODE : y'(x)=f(x,y(x))  using n-step  Adams-Moulton Methods.

The code exist  with mathematica in this link:

http://mathfaculty.fullerton.edu/mathews/n2003/AdamsBashforthMod.html

there is also the code of this method with Matlab, see please:

 http://www.math.mcgill.ca/gantumur/math579w10/matlab/abm4.m

 

But I want file.mw ( with maple)

Thank you very much for helping me.

 

 

 

 

 

 

Dear all;

 

Thanks ifor looking and help me in my work. Your remarks are welcome.Description:
 This routine uses the midpoint method to approximate the solution of
     the differential equation $y'=f(x,y)$ with the initial condition $y = y[0]$
     at $x = a$ and recursion starting value $y = y[1]$ at $x = a+h$.  The values
     are returned in $y[n]$, the value of $y$ evaluated at $x = a + nh$.       
                                                                          
Arguments:     
\begin{itemize}
\item  $f$  the integrand, a function of a two variables
                
                \item $y[]$ On input $y[0]$ is the initial value of $y$ at $x = a$, and $y[1]$
                is the value of $y$ at $x = a + h$,
                \item on output for $i \geqslant 2$
             $$ y[i] = y[i-2] + 2h f(x[i],y[i]); \quad \quad x[i] = a + i h.$$
             \end{itemize}

 
CODE USING MAPLE

 Midpoint-Method=proc(f,a,b, N)

h:=(b-a)/N;
x[0]:=a;
y[0]:=1:

 for n from 2 to N do
    x[n] := a+n*h;
    y[n+1] = y[n-1] +  2h f( x[n], y[n] );
od:
// Generate the sequence of approximations for the Improved Euler method
data_midpoint := [seq([x[n],y[n]],n=0..N)]:
//write the function;
F:=(t,y)-> value of function ;

//Generate plot which is not displayed but instead stored under the name out_fig for example
out_fig := plot(data_midpoint,style=point,color=blue)

 

Your remarks.

Thanks

 

 

 

Say we solve numerically and ODE using Maple. Say ode1:= { diff(Q(x),x)= Q(x)/3x , Q(1)=1 }

The solution is a procedure so now suppose we have another ODE where the solution appears.Say  ode2:= { diff(f(x),x)= Q(x)*x , f(1)=4}.

To extract the solution of the first ODE I set sol1:=dsolve(ode1,numeric) and Q:=proc(x) local s: return rhs(sol(x)[2]): end proc:

But now I got an error message when I trying sol2:=dsolve(ode2,numeric).

Is it possible to use a procedure in the definition of the ODE one wants to solve?

 

Hello,

I would like to solve the differential equation in the following link:

http://www.utdallas.edu/~frensley/technical/nanomes91/node2.html

 

Without using any explicit discretization. Is it possible to solve this equation with a Maple dsolve comand and some boundary condition option?

In ode solve command i generated a large array data. The output shows a large order matrix of this form

 

[110001x6 Matrix

Datatype:Anything

Storage:rectangular

order:Fortran_order].

 

I want to export this matrix into a notepad. Which can then be used for plotting in TecPlot. 

 

Looking for good response

 

 

Hi,

I have an ode like this

ODE:=(diff(T(x), x, x))+P*(S+a*(1-exp(-L*x))/L)*(diff(T(x), x))=0;

bcs:=T(0)=1,T(infinit)=0;

where P, S, L a, are all constants.

let assume that 

z=P/L^2*exp(-L*x);

subing z into the ode, we can have

ode1:=diff(T(z), z$2)+(1+z*a-P)*(diff(T(z), z)) = 0;

bcs1:=T(P/L^2)=1,T(0)=0;

Is it possible to find a closed form solution (T(x) in a compact form)?

hello,

restart:

ODE:=diff(T(z),z$2)+A1*(S-1/L+1/L*exp(-L*z))*diff(T(z),z)+A2*T(z)=0;

bcs:=T(0)=1,T(infinity)=0;

bcs:=T(0)=1,T(A3)=0;

dsolve({ODE,bcs});

where, A1, A2, A3, L, S are all constants.

i get an exact solution but is there any way around to get a more compact solution?

 

 

Hi,

I have a system of differential equations with boundary conditions:

diff(S(t), t) = -K(t)*S(t)/N, diff(K(t), t) = K(t)*S(t)/N, where S(T)=10, K(T)=20; If I would like to solve this system backward in time, is it right to re-write the system of original diff. equations in the following way:

diff(S(t), t) = K(t)*S(t)/N, diff(K(t), t) = -K(t)*S(t)/N and S(0)=10, K(0)=20 ( I simply changed the sign of the right hand of the equations and changed the boundary conditions to the inotoal ones).

Thanks,

Dmitry

 

 

Dear Experts,

When I run this code in maple I am facing with "Error, (in dsolve/numeric/bvp) initial Newton iteration is not converging".

restart:
 
 unprotect('gamma');
 lambda:=5*10^5:
 mu:=0.003:
 beta:=4*10^(-10):
 delta:=0.2:
 alpha:=0.043:
 sigma:=alpha+delta:
 k:=6.24:
 gamma:=0.65:
 A[1]:=1:
 A[2]:=1:

ics := x[1](0)=1.7*10^8, x[2](0)=0,x[3](0)=400,psi[1](50)=0,psi[2](50)=0,psi[3](50)=0:

ode1:=diff(x[1](t), t)=lambda-mu*x[1](t)-(1-beta*x[1](t)*x[3](t)*(psi[1](t)-psi[2](t))/A[1])*beta*x[1](t)*x[3](t)+delta*x[2](t),
 diff(x[2](t), t) =(1-beta*x[1](t)*x[3](t)*(psi[1](t)-psi[2](t))/A[1])*beta*x[1](t)*x[3](t)-sigma*x[2](t),
 diff(x[3](t), t) =(1+psi[3](t)*k*x[2](t)/A[2])*k*x[2](t)-gamma*x[3](t),
 diff(psi[1](t), t) =-1+1/A[1]*beta^2*x[1](t)*x[3](t)^2*(psi[1](t)-psi[2](t))^2-psi[1](t)*(-mu+beta^2*x[3](t)^2*(psi[1](t)-psi[2](t))/A[1]*x[1](t)-(1-beta*x[1](t)*x[3](t)*(psi[1](t)-psi[2](t))/A[1])*beta*x[3](t))-psi[2](t)*(-beta^2*x[3](t)^2*(psi[1](t)-psi[2](t))/A[1]*x[1](t)+(1-beta*x[1](t)*x[3](t)*(psi[1](t)-psi[2](t))/A[1])*beta*x[3](t)),
> diff(psi[2](t), t) =1/A[2]*psi[3](t)^2*k^2*x[2](t)-psi[1](t)*delta+psi[2](t)*sigma-psi[3](t)*(psi[3](t)*k^2/A[2]*x[2](t)+(1+psi[3](t)*k*x[2](t)/A[2])*k),
> diff(psi[3](t), t) = 1/A[1]*beta^2*x[1](t)^2*x[3](t)*(psi[1](t)-psi[2](t))^2-psi[1](t)*(beta^2*x[1](t)^2*(psi[1](t)-psi[2](t))/A[1]*x[3](t)-(1-beta*x[1](t)*x[3](t)*(psi[1](t)-psi[2](t))/A[1])*beta*x[1](t))-psi[2](t)*(-beta^2*x[1](t)^2*(psi[1](t)-psi[2](t))/A[1]*x[3](t)+(1-beta*x[1](t)*x[3](t)*(psi[1](t)-psi[2](t))/A[1])*beta*x[1](t))+psi[3](t)*gamma;

sol:=dsolve([ode1,ics],numeric, method = bvp[midrich]);

Error, (in dsolve/numeric/bvp) initial Newton iteration is not converging

Please help me to solve this equation on Maple.




1 2 3 4 5 6 7 Last Page 2 of 16