Nonlinear equations with two variables and a changing parameter

Hi,
I thank you for your kind help in advance!
I am solving a system of nonlinear equations with two variable x and t, and a changing parameter V. it may be sovled using a fsolve in matlab.
Then, I want to plot a figure in which the variable x or t as a function of log(V), that is,
The nonlinear equation is desribed as below code:
%The below is a system of nonlinear equations with two variables x, t, and
%a changing parameter V. 0<x<0.2, t is around 6.3e6, 0.001<V<1.
V=logspace(-3,0,10000); % A changing parameter 0.001<V<1
T=@(x,t,V) 294+8.8e-4.*t.*V.^(0.5); %Temperature
D=@(x,t,V) 1.9e-6+4.5e-7.*erf((log10(V)-log10(0.1))/0.25); %Grain size
fn=@(x) ((0.2-x)./(x-0.02))^(-2); %porosity function in normal direction
gsg=@(x,t,V) 2.4e-10.*exp(-213e3./8.31./T(x,t,V)).*fn(x).^1.7./D(x,t,V).^3; %shear strain due to granular flow
ft=@(x) (1-x./0.2).^2; %porosity funciton in shear direcdtion
gps=@(x,t,V) 1.33e-21.*exp(-213e3./8.31./T(x,t,V)).*(ft(x).*t).^1.7./D(x,t,V).^3; %shear strain due to pressure solution
F1=@(x,t,V) 2e-5.*(gsg(x,t,V)+gps(x,t,V))-V; %velocity
F2=@(x,t,V) 1e8.*(0.867+0.01.*log(gsg(x,t,V))-1.14.*x)./(1-(0.64+0.01.*log(gsg(x,t,V)).*1.14.*(0.2-x)))-t; %shear stress
for k=1:length(V)
fun=@(x,t)[F1(x,t,V(k))
F2(x,t,V(k))];
y(k)=fzero(fun,.19999,6.3e6);%plotted to get initial guess close, function blows up belond about .2 and goes imaginary
end
figure (1)
plot(log10(V),t,'k',LineWidth=2) % I want to plot t as a function of V

 Accepted Answer

%The below is a system of nonlinear equations with two variables x, t, and
%a changing parameter V. 0<x<0.2, t is around 6.3e6, 0.001<V<1.
V=logspace(-3,0,10); % A changing parameter 0.001<V<1
T=@(x,t,V) 294+8.8e-4.*t.*V.^(0.5); %Temperature
D=@(x,t,V) 1.9e-6+4.5e-7.*erf((log10(V)-log10(0.1))/0.25); %Grain size
fn=@(x) ((0.2-x)./(x-0.02))^(-2); %porosity function in normal direction
gsg=@(x,t,V) 2.4e-10.*exp(-213e3./8.31./T(x,t,V)).*fn(x).^1.7./D(x,t,V).^3; %shear strain due to granular flow
ft=@(x) (1-x./0.2).^2; %porosity funciton in shear direcdtion
gps=@(x,t,V) 1.33e-21.*exp(-213e3./8.31./T(x,t,V)).*(ft(x).*t).^1.7./D(x,t,V).^3; %shear strain due to pressure solution
F1=@(x,t,V) 2e-5.*(gsg(x,t,V)+gps(x,t,V))-V; %velocity
F2=@(x,t,V) 1e8.*(0.867+0.01.*log(gsg(x,t,V))-1.14.*x)./(1-(0.64+0.01.*log(gsg(x,t,V)).*1.14.*(0.2-x)))-t; %shear stress
for k=1:length(V)
fun=@(x,t,V)[F1(x,t,V)
F2(x,t,V)];
y(k,:)=fsolve(@(x)fun(x(1),x(2),V(k)),[.19999,6.3e6]);%plotted to get initial guess close, function blows up belond about .2 and goes imaginary
end
No solution found. fsolve stopped because the relative size of the current step is less than the value of the step size tolerance squared, but the vector of function values is not near zero as measured by the value of the function tolerance. No solution found. fsolve stopped because the relative size of the current step is less than the value of the step size tolerance squared, but the vector of function values is not near zero as measured by the value of the function tolerance. No solution found. fsolve stopped because the relative size of the current step is less than the value of the step size tolerance squared, but the vector of function values is not near zero as measured by the value of the function tolerance. No solution found. fsolve stopped because the relative size of the current step is less than the value of the step size tolerance squared, but the vector of function values is not near zero as measured by the value of the function tolerance. No solution found. fsolve stopped because the relative size of the current step is less than the value of the step size tolerance squared, but the vector of function values is not near zero as measured by the value of the function tolerance. No solution found. fsolve stopped because the relative size of the current step is less than the value of the step size tolerance squared, but the vector of function values is not near zero as measured by the value of the function tolerance. No solution found. fsolve stopped because the last step was ineffective. However, the vector of function values is not near zero, as measured by the value of the function tolerance. No solution found. fsolve stopped because the relative size of the current step is less than the value of the step size tolerance squared, but the vector of function values is not near zero as measured by the value of the function tolerance. No solution found. fsolve stopped because the last step was ineffective. However, the vector of function values is not near zero, as measured by the value of the function tolerance. No solution found. fsolve stopped because the last step was ineffective. However, the vector of function values is not near zero, as measured by the value of the function tolerance.

3 Comments

@Torsten thank you very much for your reply.
when I run the code, it appears "fsolve stopped because the problem appears regular as measured by the gradient, but the vector of function values is not near zero as measured by the value of the function tolerance."
<stopping criteria details>
fsolve stopped because the sum of squared function values, r, has gradient with
relative norm 1.945015e-07; this is less than options.OptimalityTolerance = 1.000000e-06.
However, r = 2.259413e+02, exceeds sqrt(options.FunctionTolerance) = 1.000000e-03.
Is there a good way to solve this problem? thanks a lot!
Either
  • your starting guesses for the parameters are bad,
  • you made a mistake in the implementation of the equations or
  • your equations don't have a solution.
In all three cases, I cannot help you further.
@Torsten thank you very much for your help! i guess I have got the point!

Sign in to comment.

More Answers (0)

Categories

Products

Release

R2021a

Asked:

on 3 Nov 2022

Commented:

on 4 Nov 2022

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!