How to check a numerical simulation is energy conservative?

Click For Summary

Discussion Overview

The discussion revolves around checking the energy conservation in a numerical simulation of 1D fluid wave propagation. Participants explore various aspects of energy conservation, including kinetic energy, internal energy, and the effects of boundary conditions in the context of finite volume and finite difference schemes.

Discussion Character

  • Exploratory
  • Technical explanation
  • Debate/contested
  • Mathematical reasoning

Main Points Raised

  • One participant seeks guidance on verifying energy conservation in their simulation, specifically regarding kinetic energy and boundary conditions.
  • Another participant suggests that the total kinetic energy should be conserved across cells, but acknowledges that it may not equal zero.
  • There is a discussion about whether finite difference schemes automatically conserve energy, with some participants questioning the implications of formulation and boundary conditions.
  • Participants discuss the necessity of including internal energy in the total energy conservation, noting that it may decrease as the fluid pulse expands.
  • One participant expresses uncertainty about calculating internal energy and its relation to pressure and density.
  • Another participant challenges the assumption of isothermal conditions in the fluid, arguing that kinetic energy must derive from internal energy as the fluid expands.
  • There is a mention of the interplay between density and pressure in sound wave propagation, with a participant suggesting that heat exchange may allow for constant temperature conditions.

Areas of Agreement / Disagreement

Participants do not reach a consensus on several points, including the automatic conservation of energy in finite difference schemes, the role of internal energy, and the physical implications of isothermal conditions in the fluid. Multiple competing views remain throughout the discussion.

Contextual Notes

Some participants reference specific mathematical formulations and energy balance equations, but there is uncertainty regarding the definitions and assumptions involved in these equations. The discussion also highlights potential dependencies on boundary conditions and the nature of the fluid model used.

hoomanya
Messages
86
Reaction score
0
I am modelling a 1D fluid wave propagation problem and I needed to know how I can check that my results are energy conservative. please reply, urgent. thank you.
 
Engineering news on Phys.org
Well, in your 1D simulation, each cell has a fluid density, and a fluid velocity, right. So if the density of cell i is given by \rho_i, and the velocity is given by u_i, then if you take the total \frac{1}{2} \sum_i{ \rho_i u_i^2}, then this should be conserved. Of course, your simulation might have other things, like gravitation, in which case you would need to add in the gravitational potential energy as well.
 
You are using a finite difference scheme, and you want to know if the finite difference scheme automatically conserves energy, correct?
 
phyzguy said:
if the density of cell i is given by \rho_i, and the velocity is given by u_i, then if you take the total \frac{1}{2} \sum_i{ \rho_i u_i^2}, then this should be conserved. Of course, your simulation might have other things, like gravitation, in which case you would need to add in the gravitational potential energy as well.

thank you. do I take the total over the cells, so say I have 10 cells, I add the kinetic energy term over for the 10 cells and show that they equal zero? what about time?
 
Chestermiller said:
You are using a finite difference scheme, and you want to know if the finite difference scheme automatically conserves energy, correct?
thanks, I'm using finite volume. my problem is transient.
 
hoomanya said:
thanks, I'm using finite volume. my problem is transient.
Does your finite difference scheme automatically conserve energy (i.e., is this a mathematical characteristic of your finite difference equations)?

Chet
 
  • Like
Likes   Reactions: hoomanya
Chestermiller said:
Does your finite difference scheme automatically conserve energy (i.e., is this a mathematical characteristic of your finite difference equations)?

Chet
I'm not sure. What do you mean by automatically? You mean by formulation? so if I add the discretised terms, the terms at the internal boundaries cancel out and I'm left with the terms at the two left and right boundaries.
 
hoomanya said:
I'm not sure. What do you mean by automatically? You mean by formulation? so if I add the discretised terms, the terms at the internal boundaries cancel out and I'm left with the terms at the two left and right boundaries.
The latter.
 
  • Like
Likes   Reactions: hoomanya
hoomanya said:
thank you. do I take the total over the cells, so say I have 10 cells, I add the kinetic energy term over for the 10 cells and show that they equal zero? what about time?

Yes, you add the kinetic energy for all of the cells. It won't necessarily equal zero, but it should be the same value at each time step, assuming no energy is flowing in or out of the boundaries. As chestermiller says, you could examine the equations that propagate the fluid quantities from the current time step to the next time step. These should automatically conserve the conserved quantities (mass, momentum, energy), because they should just move these quantities from one cell to an adjacent cell.
 
  • Like
Likes   Reactions: hoomanya
  • #10
phyzguy said:
Yes, you add the kinetic energy for all of the cells. It won't necessarily equal zero, but it should be the same value at each time step, assuming no energy is flowing in or out of the boundaries. As chestermiller says, you could examine the equations that propagate the fluid quantities from the current time step to the next time step. These should automatically conserve the conserved quantities (mass, momentum, energy), because they should just move these quantities from one cell to an adjacent cell.
Thanks a lot. Does the type of boundary condition used have any influence in this?
 
  • #11
Hi, so I've added my density, velocity, K.E (against space) and sum of K.E at nodes (agains time) plot, before the wave reaches the boundary so that the results are independent of the type of BC choses. The sum of KE's tend to increase at the starts as velocity is zero at the start, I wonder if internal energy is present? Am I missing something here? Thanks!
KE_plot1.jpg
KE_sum_plot1.jpg
rho_plot1.jpg
v_plot1.jpg
 
  • #12
Right. I should have said this earlier. It is the total energy that is conserved, so you need to include the internal energy. The internal energy will be decreasing as your initial fluid pulse expands. Do you know how to calculate the internal energy? If so, you should add this to the KE and plot the total energy.
 
  • Like
Likes   Reactions: hoomanya
  • #13
phyzguy said:
Right. I should have said this earlier. It is the total energy that is conserved, so you need to include the internal energy. The internal energy will be decreasing as your initial fluid pulse expands. Do you know how to calculate the internal energy? If so, you should add this to the KE and plot the total energy.
Hi, thanks again. Not quite sure, I think by integrating du = -p dv which I am guessing will give u - u_0 = -p (v-v_0), but not quite sure what the specific volume will be. I am guessing that's where density comes in.
 
  • #14
Is this a continuum model? If so, the differential energy balance equation should already involve the internal energy. Please write the differential energy balance equation you are using.

Chet
 
  • #15
Chestermiller said:
Is this a continuum model? If so, the differential energy balance equation should already involve the internal energy. Please write the differential energy balance equation you are using.

Chet
I'm not sure what you mean by a continuum model. I am not using a differential energy balance equation.
 
  • #16
hoomanya said:
Hi, thanks again. Not quite sure, I think by integrating du = -p dv which I am guessing will give u - u_0 = -p (v-v_0), but not quite sure what the specific volume will be. I am guessing that's where density comes in.

What are the fluid variables that are carried at each point in the code? You should have access to either the internal energy, or to a temperature and/or pressure from which you can calculate the internal energy. Your code must have equations for calculating the fluid variables at time t+δt in terms of the variables at time t. Do you have access to these equations?
 
  • #17
phyzguy said:
What are the fluid variables that are carried at each point in the code? You should have access to either the internal energy, or to a temperature and/or pressure from which you can calculate the internal energy. Your code must have equations for calculating the fluid variables at time t+δt in terms of the variables at time t. Do you have access to these equations?
I am solving the isothermal Euler equations and relating pressure to density using the bulk modulus of the material. I have an initial density (and hence pressure) wave and initial velocity is zero.
 
  • #18
hoomanya said:
I am solving the isothermal Euler equations and relating pressure to density using the bulk modulus of the material. I have an initial density (and hence pressure) wave and initial velocity is zero.

Well, I'm not 100% certain, but I think what you are saying does not make physical sense. You start with a fluid with an initial density and pressure. The fluid expands and drives a wave in both directions. The kinetic energy of the waves must come from the internal energy of the fluid. So the fluid cannot be isothermal. The temperature has to decrease as the wave expands. At least, this is how it seems to me.
 
  • #19
phyzguy said:
Well, I'm not 100% certain, but I think what you are saying does not make physical sense. You start with a fluid with an initial density and pressure. The fluid expands and drives a wave in both directions. The kinetic energy of the waves must come from the internal energy of the fluid. So the fluid cannot be isothermal. The temperature has to decrease as the wave expands. At least, this is how it seems to me.

Hi, so I had a think about what you said, and in the problem essentially, sound waves propagate as a result of interplay between density and pressure. Essentially, I think the rare-fractions and the compressions have enough time to exchange heat and maintain at a constant temperature depending on the speed of sound? (dp/drho = speed of sound squared). The fluid I've used is water. Please correct me if I'm wrong.
 
  • #20
So if why you are saying is correct, where does the kinetic energy of the waves come from?
 
  • #21
phyzguy said:
So if why you are saying is correct, where does the kinetic energy of the waves come from?
I was thinking of the fundamental equation of thermodynamics and how Tds = du - pdv
and so changes in the internal energy could be due to pdv or Tds independently. Can the changes in internal energy therefore no be just due the changes in pdv?
 
  • #22
I just don't know the answer. Maybe you are right, but I'm not sure.
 
  • #23
phyzguy said:
I just don't know the answer. Maybe you are right, but I'm not sure.
thanks very much for your help this far.
 

Similar threads

  • · Replies 14 ·
Replies
14
Views
2K
  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 4 ·
Replies
4
Views
1K
  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 12 ·
Replies
12
Views
2K
  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 4 ·
Replies
4
Views
1K
Replies
6
Views
3K
  • · Replies 0 ·
Replies
0
Views
2K
  • · Replies 21 ·
Replies
21
Views
2K