From: Torsten Hennig on
> Thanks,
>
> I have now fixed my equations so that they are
> correct...that is sure not going to help me!
>
> I do not know a value for T0, or as it is written in
> my equations, y(1), which is why i did not put in a
> boundary condition for it. Is there not a way to
> avoid putting it in?

I don't know the physical background for your set of
equations.
From the mathematical point of view, it is essential
to fix T at one end of the integration interval.
Imagine the equation
T'(x) = 1, x in [0;1]
If you don't fix T at 0 or 1, all functions of the
form T(x) = x + a (a in IR) are solutions - so T
becomes (nearly) arbitrary.

Best wishes
Torsten.

> What about the 'parameters'
> function...can i do something with that?
>
> Thanks
>
From: Rorie Thomson on
Ok, for the sake of ease (and just getting this program to run!) we have estimated a value for T (Y(1)), so now there are four boundary conditions, one for each value of y. My equations have been fixed so they match what i want them to say, and i have now changed the 'guess' file so that it reads as follows. I know the approximate curve i want, so i have used an equation which will match approximately it as my guess.

function y = guess(x)

y(1)=0.0036687;
y(2)=1.5*sin(2*pi*x).*(exp(-3*x)-0.001*x)+0.5*x;
y(3)=(2*pi*1.5)*sin(2*pi*x)*exp(-3*x)+1.5*sin(2*pi*x)*-3*exp(-3*x)+0.001;
y(4)=0.001*x;

However, i am still getting an error of a singular Jacobian encountered. Any further advise you can give me?

I appreciate all your help...you have been fantastic, so thank you very much again!

Torsten Hennig <Torsten.Hennig(a)umsicht.fhg.de> wrote in message <2001781929.37802.1262955083594.JavaMail.root(a)gallium.mathforum.org>...
> > Thanks,
> >
> > I have now fixed my equations so that they are
> > correct...that is sure not going to help me!
> >
> > I do not know a value for T0, or as it is written in
> > my equations, y(1), which is why i did not put in a
> > boundary condition for it. Is there not a way to
> > avoid putting it in?
>
> I don't know the physical background for your set of
> equations.
> From the mathematical point of view, it is essential
> to fix T at one end of the integration interval.
> Imagine the equation
> T'(x) = 1, x in [0;1]
> If you don't fix T at 0 or 1, all functions of the
> form T(x) = x + a (a in IR) are solutions - so T
> becomes (nearly) arbitrary.
>
> Best wishes
> Torsten.
>
> > What about the 'parameters'
> > function...can i do something with that?
> >
> > Thanks
> >
From: Torsten Hennig on
> Ok, for the sake of ease (and just getting this
> program to run!) we have estimated a value for T
> (Y(1)), so now there are four boundary conditions,
> one for each value of y. My equations have been
> fixed so they match what i want them to say, and i
> have now changed the 'guess' file so that it reads as
> follows. I know the approximate curve i want, so i
> have used an equation which will match approximately
> it as my guess.
>
> function y = guess(x)
>
> y(1)=0.0036687;
> y(2)=1.5*sin(2*pi*x).*(exp(-3*x)-0.001*x)+0.5*x;
> y(3)=(2*pi*1.5)*sin(2*pi*x)*exp(-3*x)+1.5*sin(2*pi*x)*
> -3*exp(-3*x)+0.001;
> y(4)=0.001*x;
>
> However, i am still getting an error of a singular
> Jacobian encountered. Any further advise you can
> give me?
>
> I appreciate all your help...you have been fantastic,
> so thank you very much again!
>
> Torsten Hennig <Torsten.Hennig(a)umsicht.fhg.de> wrote
> in message
> <2001781929.37802.1262955083594.JavaMail.root(a)gallium.
> mathforum.org>...
> > > Thanks,
> > >
> > > I have now fixed my equations so that they are
> > > correct...that is sure not going to help me!
> > >
> > > I do not know a value for T0, or as it is written
> in
> > > my equations, y(1), which is why i did not put in
> a
> > > boundary condition for it. Is there not a way to
> > > avoid putting it in?
> >
> > I don't know the physical background for your set
> of
> > equations.
> > From the mathematical point of view, it is
> essential
> > to fix T at one end of the integration interval.
> > Imagine the equation
> > T'(x) = 1, x in [0;1]
> > If you don't fix T at 0 or 1, all functions of the
> > form T(x) = x + a (a in IR) are solutions - so T
> > becomes (nearly) arbitrary.
> >
> > Best wishes
> > Torsten.
> >
> > > What about the 'parameters'
> > > function...can i do something with that?
> > >
> > > Thanks
> > >

Could you again post the full code, not only the guess
function ?

Best wishes
Torsten.
From: Rorie Thomson on

function constants_defined

%_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_%
%SOLINIT for guess of plot

%sol = bvp4c(odefun,bcfun,solinit,options,p1,p2...)

s=linspace(0,1,100);

solinit = bvpinit(s,'guess');

%_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_%
%BVP4C Runner using ODE file, Boundary conditions and guess

sol = bvp4c('ZeroHarmODE',@ZeroHarmBC,solinit)

x = sol.x;
y = sol.y;

plot(x,y)

%Set up Boundary Conditions
function res = ZeroHarmBC(ya,yb)
res = [ ya(1) - 0.0036687
ya(2) - 0
ya(3) - 1
ya(4) - 0];

Next file:

function dyds=ZeroHarmODE(s,y)

%State constants
s0=0.05;
S0=1;
V0=0;

%Equations to be used
% (1) (dT/ds)-T*((8*(pi^2)*y)/(1-4*(pi^2)))*(dy/ds)+2*pi*y*V=0
% (2) (dy/ds)-y_prime=0
% (3) T*(dy_prime/s)+(dT/ds)+(dT/ds)*(dy/ds)-T*4*(pi^2)*y+2*pi*y*S*(dx/ds)+2*pi*y*V*(dy/ds)=0
% (4) (dx/ds)^2+(dy/ds)^2+4*(pi^2)*(y^2)=1

% After manipulation, a vector y=[T0, y0, dy/ds, x0]
% is created and can be plugged into the equations as
%follows

%dyds=[dy1/ds, dy2/ds, dy3/ds, dy4/ds]

%dy1/ds = y(1)*((8*(pi^2)*y(2))/(1-4*(pi^2)*(y(2)^2)))*y(3)-2*pi*y(2)*V0
%dy2/ds = y(3)
%dy3/ds = (-(((y(1)*8*(pi^2)*y(2)*y(2))/(1-4*(pi^2)*y(2)^2))-2*pi*y(2)*V0)
%*y(3)+ (y(1)*4*(pi^2)*y(2))-(2*pi*y(2)*S0*dxds)+2*pi*y(2)*V0*y(3))/y(1);
%dy4/ds=sqrt(1-4*pi^2*y(2)^2-y(3)^2)

%But dy4/ds could become negitive, creating negative numbers. so an 'if
%loop' is required to stop it going negative

if 1-4*pi^2*y(2)^2-y(3)^2 <1e-12
dxds=0;
else
dxds=sqrt(1-4*pi^2*y(2)^2-y(3)^2);
end

%We want pressure only over part of the net, that is, where the fish are
%so we only apply S0 when s<s0 - s being the coordinate along the netting
%and s0 being the distnace we decide to allow pressure to be applied

%We can therefore us an 'if loop' to specify when the pressure is applied
%and when it is not. That is, when s<s0, S becomes zero

if s<s0
dyds=[y(1)*((8*(pi^2)*y(2))/(1-4*(pi^2)*(y(2)^2)))*y(3)-2*pi*y(2)*V0;
y(3);
(-(((y(1)*8*(pi^2)*y(2)*y(2))/(1-4*(pi^2)*y(2)^2))-2*pi*y(2)*V0)*y(3)+ (y(1)*4*(pi^2)*y(2))-(2*pi*y(2)*S0*dxds)+2*pi*y(2)*V0*y(3))/y(1);
dxds];
else
dyds=[y(1)*((8*(pi^2)*y(2))/(1-4*(pi^2)*(y(2)^2)))*y(3)-2*pi*y(2)*V0;
y(3);
(-(((y(1)*8*(pi^2)*y(2)*y(2))/(1-4*(pi^2)*y(2)^2))-2*pi*y(2)*V0)*y(3)+ (y(1)*4*(pi^2)*y(2))-(2*pi*y(2)*0*dxds)+2*pi*y(2)*V0*y(3))/y(1);
dxds];
end

Next file:

function y = guess(x)

y(1)=0.0036687;
y(2)=1.5*sin(2*pi*x).*(exp(-3*x)-0.001*x)+0.5*x;
y(3)=(2*pi*1.5)*cos(2*pi*x)*exp(-3*x)+1.5*sin(2*pi*x)*-3*exp(-3*x)+0.001;
y(4)=0.5*x;





Torsten Hennig <Torsten.Hennig(a)umsicht.fhg.de> wrote in message <1579949003.41998.1263036100731.JavaMail.root(a)gallium.mathforum.org>...
> > Ok, for the sake of ease (and just getting this
> > program to run!) we have estimated a value for T
> > (Y(1)), so now there are four boundary conditions,
> > one for each value of y. My equations have been
> > fixed so they match what i want them to say, and i
> > have now changed the 'guess' file so that it reads as
> > follows. I know the approximate curve i want, so i
> > have used an equation which will match approximately
> > it as my guess.
> >
> > function y = guess(x)
> >
> > y(1)=0.0036687;
> > y(2)=1.5*sin(2*pi*x).*(exp(-3*x)-0.001*x)+0.5*x;
> > y(3)=(2*pi*1.5)*sin(2*pi*x)*exp(-3*x)+1.5*sin(2*pi*x)*
> > -3*exp(-3*x)+0.001;
> > y(4)=0.001*x;
> >
> > However, i am still getting an error of a singular
> > Jacobian encountered. Any further advise you can
> > give me?
> >
> > I appreciate all your help...you have been fantastic,
> > so thank you very much again!
> >
> > Torsten Hennig <Torsten.Hennig(a)umsicht.fhg.de> wrote
> > in message
> > <2001781929.37802.1262955083594.JavaMail.root(a)gallium.
> > mathforum.org>...
> > > > Thanks,
> > > >
> > > > I have now fixed my equations so that they are
> > > > correct...that is sure not going to help me!
> > > >
> > > > I do not know a value for T0, or as it is written
> > in
> > > > my equations, y(1), which is why i did not put in
> > a
> > > > boundary condition for it. Is there not a way to
> > > > avoid putting it in?
> > >
> > > I don't know the physical background for your set
> > of
> > > equations.
> > > From the mathematical point of view, it is
> > essential
> > > to fix T at one end of the integration interval.
> > > Imagine the equation
> > > T'(x) = 1, x in [0;1]
> > > If you don't fix T at 0 or 1, all functions of the
> > > form T(x) = x + a (a in IR) are solutions - so T
> > > becomes (nearly) arbitrary.
> > >
> > > Best wishes
> > > Torsten.
> > >
> > > > What about the 'parameters'
> > > > function...can i do something with that?
> > > >
> > > > Thanks
> > > >
>
> Could you again post the full code, not only the guess
> function ?
>
> Best wishes
> Torsten.
From: Torsten Hennig on
>
> function constants_defined
>
> %_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_
> -_-_-_-_-_-_%
> %SOLINIT for guess of plot
>
> %sol = bvp4c(odefun,bcfun,solinit,options,p1,p2...)
>
> s=linspace(0,1,100);
>
> solinit = bvpinit(s,'guess');
>
> %_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_
> -_-_-_-_-_-_%
> %BVP4C Runner using ODE file, Boundary conditions and
> guess
>
> sol = bvp4c('ZeroHarmODE',@ZeroHarmBC,solinit)
>
> x = sol.x;
> y = sol.y;
>
> plot(x,y)
>
> %Set up Boundary Conditions
> function res = ZeroHarmBC(ya,yb)
> res = [ ya(1) - 0.0036687
> ya(2) - 0
> ya(3) - 1
> ya(4) - 0];
>
> Next file:
>
> function dyds=ZeroHarmODE(s,y)
>
> %State constants
> s0=0.05;
> S0=1;
> V0=0;
>
> %Equations to be used
> % (1)
> (dT/ds)-T*((8*(pi^2)*y)/(1-4*(pi^2)))*(dy/ds)+2*pi*y*V
> =0
> % (2) (dy/ds)-y_prime=0
> % (3)
> T*(dy_prime/s)+(dT/ds)+(dT/ds)*(dy/ds)-T*4*(pi^2)*y+2*
> pi*y*S*(dx/ds)+2*pi*y*V*(dy/ds)=0
> % (4) (dx/ds)^2+(dy/ds)^2+4*(pi^2)*(y^2)=1
>
> % After manipulation, a vector y=[T0, y0, dy/ds, x0]
> % is created and can be plugged into the equations as
> %follows
>
> %dyds=[dy1/ds, dy2/ds, dy3/ds, dy4/ds]
>
> %dy1/ds =
> y(1)*((8*(pi^2)*y(2))/(1-4*(pi^2)*(y(2)^2)))*y(3)-2*pi
> *y(2)*V0
> %dy2/ds = y(3)
> %dy3/ds =
> (-(((y(1)*8*(pi^2)*y(2)*y(2))/(1-4*(pi^2)*y(2)^2))-2*p
> i*y(2)*V0)
> %*y(3)+
> (y(1)*4*(pi^2)*y(2))-(2*pi*y(2)*S0*dxds)+2*pi*y(2)*V0*
> y(3))/y(1);
> %dy4/ds=sqrt(1-4*pi^2*y(2)^2-y(3)^2)
>
> %But dy4/ds could become negitive, creating negative
> numbers. so an 'if
> %loop' is required to stop it going negative
>
> if 1-4*pi^2*y(2)^2-y(3)^2 <1e-12
> dxds=0;
> else
> dxds=sqrt(1-4*pi^2*y(2)^2-y(3)^2);
> end
>
> %We want pressure only over part of the net, that is,
> where the fish are
> %so we only apply S0 when s<s0 - s being the
> coordinate along the netting
> %and s0 being the distnace we decide to allow
> pressure to be applied
>
> %We can therefore us an 'if loop' to specify when the
> pressure is applied
> %and when it is not. That is, when s<s0, S becomes
> zero
>
> if s<s0
>
>
>
> dyds=[y(1)*((8*(pi^2)*y(2))/(1-4*(pi^2)*(y(2)^2)))*y(
> 3)-2*pi*y(2)*V0;
> y(3);
>
>
>
> (-(((y(1)*8*(pi^2)*y(2)*y(2))/(1-4*(pi^2)*y(2)^2))-2*
> pi*y(2)*V0)*y(3)+
> (y(1)*4*(pi^2)*y(2))-(2*pi*y(2)*S0*dxds)+2*pi*y(2)*V0*
> y(3))/y(1);
> dxds];
> else
>
>
>
> dyds=[y(1)*((8*(pi^2)*y(2))/(1-4*(pi^2)*(y(2)^2)))*y(
> 3)-2*pi*y(2)*V0;
> y(3);
>
>
>
> (-(((y(1)*8*(pi^2)*y(2)*y(2))/(1-4*(pi^2)*y(2)^2))-2*
> pi*y(2)*V0)*y(3)+
> (y(1)*4*(pi^2)*y(2))-(2*pi*y(2)*0*dxds)+2*pi*y(2)*V0*y
> (3))/y(1);
> dxds];
> end
>
> Next file:
>
> function y = guess(x)
>
> y(1)=0.0036687;
> y(2)=1.5*sin(2*pi*x).*(exp(-3*x)-0.001*x)+0.5*x;
> y(3)=(2*pi*1.5)*cos(2*pi*x)*exp(-3*x)+1.5*sin(2*pi*x)*
> -3*exp(-3*x)+0.001;
> y(4)=0.5*x;
>
>
>

Since all boundary conditions are defined at the left
endpoint of the interval of integration, this is an
initial value problem, not a boundary value problem.
Try ODE45 instead of BVP4C.

Best wishes
Torsten.