mirror of
https://git.gfz-potsdam.de/naaice/tug.git
synced 2025-12-13 09:28:23 +01:00
add: Implementation of max time step
This commit is contained in:
parent
a72217f6a2
commit
f4924ac8b2
@ -40,8 +40,8 @@ int main(int argc, char *argv[]) {
|
||||
|
||||
// Simulation
|
||||
Simulation sim = Simulation(grid, bc, FTCS_APPROACH);
|
||||
sim.setTimestep(0.001);
|
||||
sim.setIterations(7000);
|
||||
//sim.setTimestep(0.001);
|
||||
sim.setIterations(2);
|
||||
sim.setOutputCSV(CSV_OUTPUT_VERBOSE);
|
||||
|
||||
|
||||
|
||||
@ -13,7 +13,23 @@ Simulation::Simulation(Grid grid, Boundary bc, APPROACH approach) : grid(grid),
|
||||
this->approach = approach;
|
||||
|
||||
//TODO calculate max time step
|
||||
this->timestep = 0.01;
|
||||
|
||||
double deltaRowSquare = grid.getDeltaRow() * grid.getDeltaRow();
|
||||
double deltaColSquare = grid.getDeltaCol() * grid.getDeltaCol();
|
||||
|
||||
double minDelta = (deltaRowSquare < deltaColSquare) ? deltaRowSquare : deltaColSquare;
|
||||
double maxAlphaX = grid.getAlphaX().maxCoeff();
|
||||
double maxAlphaY = grid.getAlphaY().maxCoeff();
|
||||
double maxAlpha = (maxAlphaX > maxAlphaY) ? maxAlphaX : maxAlphaY;
|
||||
|
||||
//double maxStableTimestep = minDelta / (2*maxAlpha); // Formula from Marco --> seems to be unstable
|
||||
double maxStableTimestep = 1 / (4 * maxAlpha * ((1/deltaRowSquare) + (1/deltaColSquare))); // Formula from Wikipedia
|
||||
|
||||
cout << maxStableTimestep << endl;
|
||||
|
||||
this->timestep = maxStableTimestep;
|
||||
|
||||
|
||||
this->iterations = 1000;
|
||||
this->csv_output = CSV_OUTPUT_OFF;
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user