CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > General Forums > Main CFD Forum

Solving 1D Navier-Stokes equation using ode45 MATLAB

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   April 11, 2020, 15:28
Default Solving 1D Navier-Stokes equation using ode45 MATLAB
  #1
New Member
 
Neelay Doshi
Join Date: Mar 2019
Posts: 7
Rep Power: 7
Neelay Doshi is on a distinguished road
Hello everyone!

I am trying to solve 1-dimension, inviscid and compressible Navier-Stokes equation using the ode45 function in MATLAB. I have derived the necessary governing equation and have attached them in the post.

I understand that normally these are solved using FDM, FVM etc, but I wish to solve them using ode45 as it would require much lesser computational time.

As you can see, the equations are coupled and every equation contains a derivative term of another variable which may not be calculated yet.

For instance, as per my understanding, if I were create an ode function containing the 4 system of equations as per the order given in the attachment, then ode45 would first try to solve the energy equation (dT/dx) but it wouldn't know the value of the derivative of velocity (du/dx) as it has not been calculated yet, and so the solver would use du/dx=0, which would be incorrect.

Is their anyother way to solve these coupled odes? Kindly correct me if I am mistaken.
Attached Images
File Type: jpg Governing_Eq.jpg (60.6 KB, 28 views)
Neelay Doshi is offline   Reply With Quote

Old   April 11, 2020, 15:47
Default
  #2
Senior Member
 
Filippo Maria Denaro
Join Date: Jul 2010
Posts: 6,882
Rep Power: 73
FMDenaro has a spectacular aura aboutFMDenaro has a spectacular aura aboutFMDenaro has a spectacular aura about
Note sure you addressed correctly the question.
The inviscid flow model is the Euler system of equations not the Navier-Stokes.
Then you are assuming a steady condition that means this set of equations



rho*u=G=constant (mass)



G*du/dx +dp/dx=0 (momentum)


G*d/dx (E+p/rho) =0 (total energy)


Are you really want to solve numerically this system??
FMDenaro is offline   Reply With Quote

Old   April 11, 2020, 15:57
Default
  #3
New Member
 
Neelay Doshi
Join Date: Mar 2019
Posts: 7
Rep Power: 7
Neelay Doshi is on a distinguished road
Yes I meant Euler system, but the governing equations you have written and the ones i have attached are essentially the same, i have simply rearranged the terms.

Yes I would like to try to solve it numerically (using ode45). Do you suggest that it is not possible?
Neelay Doshi is offline   Reply With Quote

Old   April 11, 2020, 16:05
Default
  #4
Senior Member
 
Filippo Maria Denaro
Join Date: Jul 2010
Posts: 6,882
Rep Power: 73
FMDenaro has a spectacular aura aboutFMDenaro has a spectacular aura aboutFMDenaro has a spectacular aura about
Quote:
Originally Posted by Neelay Doshi View Post
Yes I meant Euler system, but the governing equations you have written and the ones i have attached are essentially the same, i have simply rearranged the terms.

Yes I would like to try to solve it numerically (using ode45). Do you suggest that it is not possible?



As you see, the energy equation is simply integrated as E+p/rho=constant, along with the mass constraint G=constant you get from the momentum G*u+p= constant.


There is nothing to solve numerically
FMDenaro is offline   Reply With Quote

Old   April 11, 2020, 16:14
Default
  #5
Senior Member
 
Lucky
Join Date: Apr 2011
Location: Orlando, FL USA
Posts: 5,754
Rep Power: 66
LuckyTran has a spectacular aura aboutLuckyTran has a spectacular aura aboutLuckyTran has a spectacular aura about
Quote:
Originally Posted by Neelay Doshi View Post
then ode45 would first try to solve the energy equation (dT/dx) but it wouldn't know the value of the derivative of velocity (du/dx) as it has not been calculated yet, and so the solver would use du/dx=0, which would be incorrect.
.

but why would the solver choose du/dx=0 and not -12345, hmm? Think about it...


What you are missing are the initial conditions and boundary conditions for Euler equations. Your problem definition is not complete you state the governing equations, the initial conditions, and boundary conditions. You should know the values of rho,p,T,U as well as drho/dx,dp/dx,dT/dx,dU/dx on the boundaries. You are choosing to approach this with ode45, making it akin to an intitial value problem instead of a boundary value problem. Still, you should know their values at least at x=0.

Last edited by LuckyTran; April 11, 2020 at 23:55.
LuckyTran is offline   Reply With Quote

Old   April 12, 2020, 05:17
Default
  #6
New Member
 
Neelay Doshi
Join Date: Mar 2019
Posts: 7
Rep Power: 7
Neelay Doshi is on a distinguished road
Quote:
Originally Posted by LuckyTran View Post
but why would the solver choose du/dx=0 and not -12345, hmm? Think about it...
I have attached a snip of the ode45 function I have written, as you can see, I need to initialize the derivative column matrix to zero. If there is another method then kindly guide me.

Quote:
Originally Posted by LuckyTran View Post
Your problem definition is not complete you state the governing equations, the initial conditions, and boundary conditions. You should know the values of rho,p,T,U as well as drho/dx,dp/dx,dT/dx,dU/dx on the boundaries.
I do have the initial conditions (at x=0). I am feeding the ode45 function with the initial values of T, P, rho and u as the input "y". As the equations are 1st order odes, these conditions should suffice as per my understanding and I should not require the derivative values (drho/dx,dp/dx,dT/dx,dU/dx) and infact these values are supposed to be calculated by ode45.

Kindly tell me where have I gone wrong in writing the function code.
Attached Images
File Type: jpg ode45_function_code.JPG (61.1 KB, 17 views)
Neelay Doshi is offline   Reply With Quote

Old   April 12, 2020, 19:01
Default
  #7
Senior Member
 
Lucky
Join Date: Apr 2011
Location: Orlando, FL USA
Posts: 5,754
Rep Power: 66
LuckyTran has a spectacular aura aboutLuckyTran has a spectacular aura aboutLuckyTran has a spectacular aura about
Quote:
Originally Posted by Neelay Doshi View Post
I have attached a snip of the ode45 function I have written, as you can see, I need to initialize the derivative column matrix to zero. If there is another method then kindly guide me.
You don't NEED to. You could just as easily initialize it with ones(). Actually you can even initialize it with malloc(). Allocating space for a variable and initializing the problem are different things.

What you need to do is put in x=0 (i.e. put the initial conditions in) into the system and solve for all the missing derivatives (not using ode45 because it is not a coupled system of ode's you are solving but an algebraic linear system).
LuckyTran is offline   Reply With Quote

Reply

Tags
navier stokes equations, ode solving


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
[solidMechanics] Support thread for "Solid Mechanics Solvers added to OpenFOAM Extend" bigphil OpenFOAM CC Toolkits for Fluid-Structure Interaction 686 December 22, 2022 10:10
HeatSource BC to the whole region in chtMultiRegionHeater xsa OpenFOAM Running, Solving & CFD 3 November 7, 2016 06:07
pisoFoam with k-epsilon turb blows up - Some questions Heroic OpenFOAM Running, Solving & CFD 26 December 17, 2012 04:34
Orifice Plate with a fully developed flow - Problems with convergence jonmec OpenFOAM Running, Solving & CFD 3 July 28, 2011 06:24
Error while running rhoPisoFoam.. nileshjrane OpenFOAM Running, Solving & CFD 8 August 26, 2010 13:50


All times are GMT -4. The time now is 03:03.