Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

How to check a numerical simulation is energy conservative?

  1. Nov 14, 2015 #1
    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.
     
  2. jcsd
  3. Nov 14, 2015 #2

    phyzguy

    User Avatar
    Science Advisor

    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 [itex]\rho_i[/itex], and the velocity is given by [itex]u_i[/itex], then if you take the total [itex]\frac{1}{2} \sum_i{ \rho_i u_i^2}[/itex], 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.
     
  4. Nov 14, 2015 #3
    You are using a finite difference scheme, and you want to know if the finite difference scheme automatically conserves energy, correct?
     
  5. Nov 15, 2015 #4
    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?
     
  6. Nov 15, 2015 #5
    thanks, I'm using finite volume. my problem is transient.
     
  7. Nov 15, 2015 #6
    Does your finite difference scheme automatically conserve energy (i.e., is this a mathematical characteristic of your finite difference equations)?

    Chet
     
  8. Nov 15, 2015 #7
    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.
     
  9. Nov 15, 2015 #8
    The latter.
     
  10. Nov 15, 2015 #9

    phyzguy

    User Avatar
    Science Advisor

    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.
     
  11. Nov 15, 2015 #10
    Thanks alot. Does the type of boundary condition used have any influence in this?
     
  12. Nov 15, 2015 #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
     
  13. Nov 16, 2015 #12

    phyzguy

    User Avatar
    Science Advisor

    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.
     
  14. Nov 16, 2015 #13
    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.
     
  15. Nov 16, 2015 #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
     
  16. Nov 16, 2015 #15
    I'm not sure what you mean by a continuum model. I am not using a differential energy balance equation.
     
  17. Nov 16, 2015 #16

    phyzguy

    User Avatar
    Science Advisor

    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?
     
  18. Nov 16, 2015 #17
    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.
     
  19. Nov 16, 2015 #18

    phyzguy

    User Avatar
    Science Advisor

    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.
     
  20. Nov 17, 2015 #19
    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.
     
  21. Nov 17, 2015 #20

    phyzguy

    User Avatar
    Science Advisor

    So if why you are saying is correct, where does the kinetic energy of the waves come from?
     
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook




Similar Discussions: How to check a numerical simulation is energy conservative?
Loading...