CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > SU2

Initialization with two different initial states-Shock tube problem.!!!

Register Blogs Community New Posts Updated Threads Search

Like Tree4Likes
  • 1 Post By hlk
  • 2 Post By Vino
  • 1 Post By mhd_mrt

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   October 14, 2014, 05:32
Smile Initialization with two different initial states-Shock tube problem.!!!
  #1
Senior Member
 
Vino
Join Date: Mar 2013
Posts: 130
Rep Power: 13
Vino is on a distinguished road
Hi, I would like to simulate shock tube problem, for which I need to set two different initial conditions. The tube is 800 unit long, first half portion of the domain need to be initialized with high pressure & second half to be low pressure. I tried the following in "SetInitialCondition" class and its not working. Its not starting the simulation.


Code:
if (shocktube) { 
       
      double *Coord, Pressure, Temperature, Density, 
      VelocityX, VelocityY, Energy, ModVel2; 
       
      double Gamma_Minus_One = Gamma - 1.0; 
      double Gas_Constant = config->GetGas_Constant(); 
       
        for (iMesh = 0; iMesh <= config->GetMGLevels(); iMesh++) { 
         
            for (iPoint = 0; iPoint < geometry[iMesh]->GetnPoint(); iPoint++) { 
             
            Coord = geometry[iMesh]->node[iPoint]->GetCoord(); 
 
            if(Coord[0] <= 400) { 
                             
            Pressure    = 5*101325.0;     
            Temperature = 288.0; 
            Density     = Pressure/(Gas_Constant*Temperature); 
            VelocityX   = 0.0; 
            VelocityY   = 0.0; 
            ModVel2     = 0.0; 
            Energy      = Pressure/(Density*Gamma_Minus_One)+0.5*ModVel2; 
 
            solver_container[iMesh][FLOW_SOL]->node[iPoint]->SetSolution(0, Density); 
            solver_container[iMesh][FLOW_SOL]->node[iPoint]->SetSolution(1, VelocityX);  
            solver_container[iMesh][FLOW_SOL]->node[iPoint]->SetSolution(2, VelocityY); 
            solver_container[iMesh][FLOW_SOL]->node[iPoint]->SetSolution(nVar-1,Energy); 
             
                         
           } 
         
              else { 
                                 
            Pressure    = 101325.0;     
            Temperature = 288.0; 
            Density     = Pressure/(Gas_Constant*Temperature); 
            VelocityX   = 0.0; 
            VelocityY   = 0.0; 
            ModVel2     = 0.0; 
            Energy      = Pressure/(Density*Gamma_Minus_One)+0.5*ModVel2; 
 
            solver_container[iMesh][FLOW_SOL]->node[iPoint]->SetSolution(0, Density); 
            solver_container[iMesh][FLOW_SOL]->node[iPoint]->SetSolution(1, VelocityX); 
            solver_container[iMesh][FLOW_SOL]->node[iPoint]->SetSolution(2, VelocityY); 
            solver_container[iMesh][FLOW_SOL]->node[iPoint]->SetSolution(nVar-1,Energy); 
                                             
            } 
             
          } 
                         /*--- Set the MPI communication ---*/ 
            solver_container[iMesh][FLOW_SOL]->Set_MPI_Solution(geometry[iMesh], config); 
       
       } 
        
 
  }

Thanks .!!!!
Vino is offline   Reply With Quote

Old   October 20, 2014, 13:55
Default
  #2
hlk
Senior Member
 
Heather Kline
Join Date: Jun 2013
Posts: 309
Rep Power: 13
hlk is on a distinguished road
Quote:
Originally Posted by Vino View Post
Hi, I would like to simulate shock tube problem, for which I need to set two different initial conditions. The tube is 800 unit long, first half portion of the domain need to be initialized with high pressure & second half to be low pressure. I tried the following in "SetInitialCondition" class and its not working. Its not starting the simulation.


Code:
if (shocktube) { 
       
      double *Coord, Pressure, Temperature, Density, 
      VelocityX, VelocityY, Energy, ModVel2; 
       
      double Gamma_Minus_One = Gamma - 1.0; 
      double Gas_Constant = config->GetGas_Constant(); 
       
        for (iMesh = 0; iMesh <= config->GetMGLevels(); iMesh++) { 
         
            for (iPoint = 0; iPoint < geometry[iMesh]->GetnPoint(); iPoint++) { 
             
            Coord = geometry[iMesh]->node[iPoint]->GetCoord(); 
 
            if(Coord[0] <= 400) { 
                             
            Pressure    = 5*101325.0;     
            Temperature = 288.0; 
            Density     = Pressure/(Gas_Constant*Temperature); 
            VelocityX   = 0.0; 
            VelocityY   = 0.0; 
            ModVel2     = 0.0; 
            Energy      = Pressure/(Density*Gamma_Minus_One)+0.5*ModVel2; 
 
            solver_container[iMesh][FLOW_SOL]->node[iPoint]->SetSolution(0, Density); 
            solver_container[iMesh][FLOW_SOL]->node[iPoint]->SetSolution(1, VelocityX);  
            solver_container[iMesh][FLOW_SOL]->node[iPoint]->SetSolution(2, VelocityY); 
            solver_container[iMesh][FLOW_SOL]->node[iPoint]->SetSolution(nVar-1,Energy); 
             
                         
           } 
         
              else { 
                                 
            Pressure    = 101325.0;     
            Temperature = 288.0; 
            Density     = Pressure/(Gas_Constant*Temperature); 
            VelocityX   = 0.0; 
            VelocityY   = 0.0; 
            ModVel2     = 0.0; 
            Energy      = Pressure/(Density*Gamma_Minus_One)+0.5*ModVel2; 
 
            solver_container[iMesh][FLOW_SOL]->node[iPoint]->SetSolution(0, Density); 
            solver_container[iMesh][FLOW_SOL]->node[iPoint]->SetSolution(1, VelocityX); 
            solver_container[iMesh][FLOW_SOL]->node[iPoint]->SetSolution(2, VelocityY); 
            solver_container[iMesh][FLOW_SOL]->node[iPoint]->SetSolution(nVar-1,Energy); 
                                             
            } 
             
          } 
                         /*--- Set the MPI communication ---*/ 
            solver_container[iMesh][FLOW_SOL]->Set_MPI_Solution(geometry[iMesh], config); 
       
       } 
        
 
  }
Thanks .!!!!
Thank you for your interest in SU2
Could you please provide more detail about what you mean by "it is not starting the simulation"? Is there an error message? Are any output files produced? Does it freeze indefinitely?
Also, have you tried introducing the following?
solver_container[iMesh][FLOW_SOL]->Set_MPI_Solution_Old(geometry[iMesh], config);
If the code is just freezing indefinitely, it may be that it is getting stuck because mpi is waiting for the old solution information somewhere - that shouldn't be a problem in serial, but it's something to check. You may also want to check that the code does execute the code snippet you posted - if no solution is being set at all that could be why the simulation does not proceed.

One thing you could try is to look at the restart file format, and set up a restart file that has the initial conditions you want, and then set SU2 to restart a solution from that file with:

RESTART_SOL = NO
SOLUTION_FLOW_FILENAME = (your initial condition file).dat
Vino likes this.
hlk is offline   Reply With Quote

Old   October 20, 2014, 14:07
Default
  #3
Senior Member
 
Vino
Join Date: Mar 2013
Posts: 130
Rep Power: 13
Vino is on a distinguished road
Quote:
Originally Posted by hlk View Post
Thank you for your interest in SU2
Could you please provide more detail about what you mean by "it is not starting the simulation"? Is there an error message? Are any output files produced? Does it freeze indefinitely?
Also, have you tried introducing the following?
solver_container[iMesh][FLOW_SOL]->Set_MPI_Solution_Old(geometry[iMesh], config);
If the code is just freezing indefinitely, it may be that it is getting stuck because mpi is waiting for the old solution information somewhere - that shouldn't be a problem in serial, but it's something to check. You may also want to check that the code does execute the code snippet you posted - if no solution is being set at all that could be why the simulation does not proceed.

One thing you could try is to look at the restart file format, and set up a restart file that has the initial conditions you want, and then set SU2 to restart a solution from that file with:

RESTART_SOL = NO
SOLUTION_FLOW_FILENAME = (your initial condition file).dat
I meant, the initial conditions were not evolving in time. It happened because of the "SetInitialCondition" has been called for each time & it was replacing my solution with initial conditions. I changed it as follows and its working fine.
Code:
if (shocktube && ExtIter==0) {}
Thanks a lot for your reply.!!!
Vino is offline   Reply With Quote

Old   September 27, 2017, 19:32
Default SU2 Shock Tube Initialization
  #4
Member
 
Mehdi Mortazawy
Join Date: Mar 2017
Posts: 30
Rep Power: 9
mhd_mrt is on a distinguished road
Hello All,

I am super new to SU2 and would like to know if there is any testcase or tutotial regarding the classical unsteady Shock Tube problem in 2D?

I have created a 2D rectangular mesh in Pointwise with left side vertical line named as "inlet", right line as "outlet", top and bottom as "wall", and would like to know how I should define my Boundary conditions? Also, how can I initialize in SU2?

Please be very generous in your explanation as I am very new to SU2 and would like to use SU2 for my Masters Thesis to validate an Experimental PHD Thesis.


I would really appreciate any comment and advice.


Thank you!


https://www.dropbox.com/s/qxxbly4i68..._6034.JPG?dl=0
mhd_mrt is offline   Reply With Quote

Old   September 29, 2017, 16:09
Default
  #5
Member
 
Mehdi Mortazawy
Join Date: Mar 2017
Posts: 30
Rep Power: 9
mhd_mrt is on a distinguished road
Quote:
Originally Posted by Vino View Post
I meant, the initial conditions were not evolving in time. It happened because of the "SetInitialCondition" has been called for each time & it was replacing my solution with initial conditions. I changed it as follows and its working fine.
Code:
if (shocktube && ExtIter==0) {}
Thanks a lot for your reply.!!!
Hello Vino,

I am trying to simulate a 2D shock tube using SU2, and I am having difficulty understanding how to initialize the high pressure and low pressure zones. I would really appreciate if you could please explain more in details which .cpp files are you editing and where do you input the above code?

Thanks!
mhd_mrt is offline   Reply With Quote

Old   October 1, 2017, 11:50
Default
  #6
Senior Member
 
Vino
Join Date: Mar 2013
Posts: 130
Rep Power: 13
Vino is on a distinguished road
Dear Mehdi,

To simulate shocktube, you need to specify left and right states (two different initial states). A quick fix will be to run the simulation for 1 iter, then modify the restart file to initialize left and right states, then restart the simulation from restart file. It should work.

Another way is to add a initial condition specific to shocktube problem.

in "solver_direct_mean.cpp"

in "CEulerSolver::SetInitialCondition()" class {

......

if (shocktube)

then specify different. initial conditions
......
}

I don't know whether there is any better way to do. But this will help you to start with at least. It is difficult to post all the required modification here, hence I have added it in github. you can have a look at it. Its working, but results are not validated yet.

https://github.com/vino-123/SU2_v.50_shock_tube

thanks,
vino.
AshwaniAssam and mhd_mrt like this.
Vino is offline   Reply With Quote

Old   October 1, 2017, 12:25
Default
  #7
Member
 
Mehdi Mortazawy
Join Date: Mar 2017
Posts: 30
Rep Power: 9
mhd_mrt is on a distinguished road
Quote:
Originally Posted by Vino View Post
Dear Mehdi,

To simulate shocktube, you need to specify left and right states (two different initial states). A quick fix will be to run the simulation for 1 iter, then modify the restart file to initialize left and right states, then restart the simulation from restart file. It should work.

Another way is to add a initial condition specific to shocktube problem.

in "solver_direct_mean.cpp"

in "CEulerSolver::SetInitialCondition()" class {

......

if (shocktube)

then specify different. initial conditions
......
}

I don't know whether there is any better way to do. But this will help you to start with at least. It is difficult to post all the required modification here, hence I have added it in github. you can have a look at it. Its working, but results are not validated yet.

https://github.com/vino-123/SU2_v.50_shock_tube

thanks,
vino.
Dear Vino,

Thank you so much for the detail reply. I really appreciate that and the fact that you posted the code along with the example. Its a great help and start for me to learn how to modify the source code towards my needs/ goals in future. It is interesting to note that the Shocktube (config file) example you have posted as a test case does not define any Unsteady Simulation parameter inside it. Regardless, I will give this a try tonight and will keep you updated about the results. We will be using SU2's shock capturing scheme to validate experimental work as a thesis.

Once again, thank you very much for the detailed information!

Mehdi
mhd_mrt is offline   Reply With Quote

Old   October 2, 2017, 22:57
Default
  #8
Member
 
Mehdi Mortazawy
Join Date: Mar 2017
Posts: 30
Rep Power: 9
mhd_mrt is on a distinguished road
Quote:
Originally Posted by Vino View Post
Dear Mehdi,

To simulate shocktube, you need to specify left and right states (two different initial states). A quick fix will be to run the simulation for 1 iter, then modify the restart file to initialize left and right states, then restart the simulation from restart file. It should work.

Another way is to add a initial condition specific to shocktube problem.

in "solver_direct_mean.cpp"

in "CEulerSolver::SetInitialCondition()" class {

......

if (shocktube)

then specify different. initial conditions
......
}

I don't know whether there is any better way to do. But this will help you to start with at least. It is difficult to post all the required modification here, hence I have added it in github. you can have a look at it. Its working, but results are not validated yet.

https://github.com/vino-123/SU2_v.50_shock_tube

thanks,
vino.
Dear Vino,

So just posting an update on this. It now works perfectly and the results look pretty interesting!
Vino likes this.
mhd_mrt is offline   Reply With Quote

Old   May 22, 2018, 14:38
Thumbs up similar problem for simulate mixing layer
  #9
New Member
 
Chao
Join Date: Aug 2016
Posts: 1
Rep Power: 0
dtyclm is on a distinguished road
Dear Vino,

Your reply is very useful.
In fact, recently I am trying to simulate mixing layer with su2. I also have such initialization problem. In my case I think only difference is just I have two flow which are parallel to each other with opposite velocity and placed horizontally.
I am planning to use Navier-Stokes instead of Euler and trying to figure out where to initialize the flow properties and modify the code similarly as you did. I check your modified code but I found only Euler has CEulerSolver::SetInitialCondition(...). In Navier-Stokes solver, is there such initial condition setting function?

I appreciate any response from you in advance!

Thanks
Chao


Quote:
Originally Posted by Vino View Post
Dear Mehdi,

To simulate shocktube, you need to specify left and right states (two different initial states). A quick fix will be to run the simulation for 1 iter, then modify the restart file to initialize left and right states, then restart the simulation from restart file. It should work.

Another way is to add a initial condition specific to shocktube problem.

in "solver_direct_mean.cpp"

in "CEulerSolver::SetInitialCondition()" class {

......

if (shocktube)

then specify different. initial conditions
......
}

I don't know whether there is any better way to do. But this will help you to start with at least. It is difficult to post all the required modification here, hence I have added it in github. you can have a look at it. Its working, but results are not validated yet.

https://github.com/vino-123/SU2_v.50_shock_tube

thanks,
vino.
dtyclm is offline   Reply With Quote

Old   August 3, 2022, 12:20
Default
  #10
Senior Member
 
Ashwani
Join Date: Sep 2013
Location: Hyderabad
Posts: 154
Rep Power: 12
AshwaniAssam is on a distinguished road
Though the post is old. However, if you follow the SU2 coding style, you shall use the same function mentioned in Euler Solver to set the initial condition.
AshwaniAssam is offline   Reply With Quote

Reply


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
Help for the small implementation in turbulence model shipman OpenFOAM Programming & Development 25 March 19, 2014 10:08
Unstabil Simulation with chtMultiRegionFoam mbay101 OpenFOAM Running, Solving & CFD 13 December 28, 2013 13:12
SLTS+rhoPisoFoam: what is rDeltaT??? nileshjrane OpenFOAM Running, Solving & CFD 4 February 25, 2013 04:13
Problems with simulating TurbFOAM barath.ezhilan OpenFOAM 13 July 16, 2009 05:55
Differences between serial and parallel runs carsten OpenFOAM Bugs 11 September 12, 2008 11:16


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