Need help solving and plotting a first order pde

I've tried using ode45 however the values for tau come out to be negative which shouldn't be possible
I need to plot tau vs gamma
The code for the same :
clc, clearvars, close all
eta0 = 8080;
lambda = 1.109;
gamma = logspace(-3, 3, 100);
f = @(t, tau) (-(tau + eta0 * interp1(linspace(0, 100, length(gamma)), gamma, t)) / lambda);
[t, tau] = ode45(f, [0, 100], 0);
gammaint = interp1(linspace(0, 100, length(gamma)), gamma, t);
loglog(tau,gammaint,'.')

6 Comments

We miss your code.
And why do you say it's a PDE ? Isn't "t" the only independent variable ?
I'm a bit confused regarding the same, since the symbol is that of a partial derivative
also gamma dot is "shear rate" the word rate implies that it is a derivative itself
p.s I've edited the post to include the code as well
Should the variable "gamma" in your code represent gamma or gamma_dot = d(gamma)/dt ?
It should be gamma itself since ive been asked to specify gamma as logspace (-3,3,100)
But the equation says gamma_dot ... Thus you will have to differentiate gamma before you put it in your equation, haven't you ?
gamma = logspace(-3,3,100);
gamma_dot(1) = (gamma(2)-gamma(1));
for i = 2:numel(gamma)-1
gamma_dot(i) = (gamma(i+1)-gamma(i-1))/2;
end
gamma_dot(end+1) = gamma(end)-gamma(end-1);
hold on
plot(gamma)
plot(gamma_dot)
hold off
grid on
Your question looks identical to this one. Can we merge them? If they are not the same, could you please resolve one of them before moving on to the other?

Sign in to comment.

Answers (1)

You have the derivative of tau with respect to t, so tau is a function of t.
You wish to plot tau vs gamma, so tau is also a function of gamma.
When you have something that is a function of two variables, then you have a PDE rather than an ODE. ode45 and the other ode* functions are only for ODE.
You appear to have as in the derivative of gamma, so this appears to have two derivatives -- but you only have one equation. To solve you need as many equations as the sum of the highest derivative order for each variable. First derivative for gamma plus first derivative for tau --> 1 + 1 = 2 so you need two equations.

1 Comment

syms tau(t) lambda_1 eta_0 gamma__dot
tau__dot = diff(tau);
ode = tau + lambda_1 * tau__dot == - eta_0 * gamma__dot
ode(t) = 
sol = dsolve(ode)
sol = 
Assuming positive lambda_1, the larger t gets, the more the exp() goes to 0 so the more the C_1 term goes to 0. Subtract off the other term and you can certainly go negative. The only way to prevent that is negative lambda_1 or negative product of (eta_0 and gamma__dot) so that you are adding a value instead of subtracting.

Sign in to comment.

Products

Release

R2023b

Asked:

on 30 Oct 2023

Commented:

on 17 Nov 2023

Community Treasure Hunt

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

Start Hunting!