From fdf5346ff97f3a0209bac3d6562bfa0fb815f8b4 Mon Sep 17 00:00:00 2001 From: Axel Huebl Date: Fri, 25 Apr 2014 16:15:03 +0200 Subject: [PATCH 1/2] Fix #165 Use Corrected CFL Criteria A. Taflove & M. E. Brodwin IEEE Trans. on Microwave Theory and Techniques, August 1975 Formula (7) --- .../unitless/gridConfig.unitless | 21 ++++++++++++------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/src/picongpu/include/simulation_defines/unitless/gridConfig.unitless b/src/picongpu/include/simulation_defines/unitless/gridConfig.unitless index 5317ebf081..3529297a11 100644 --- a/src/picongpu/include/simulation_defines/unitless/gridConfig.unitless +++ b/src/picongpu/include/simulation_defines/unitless/gridConfig.unitless @@ -35,15 +35,20 @@ namespace picongpu CONST_VECTOR(float_X,simDim,cellSize,CELL_WIDTH,CELL_HEIGHT,CELL_DEPTH); #if (SIMDIM==DIM3) - const float_X CELL_VOLUME = CELL_WIDTH * CELL_HEIGHT *CELL_DEPTH; - /* Courant-Friedrichs-Levy-Condition for Field Solver: */ - PMACC_CASSERT_MSG(Courant_Friedrichs_Levy_condition_failure____check_your_gridConfig_param_file, - (PMACC_MIN(CELL_DEPTH,PMACC_MIN(CELL_WIDTH,CELL_HEIGHT))/SPEED_OF_LIGHT/DELTA_T)>1.77f); + const float_X CELL_VOLUME = CELL_WIDTH * CELL_HEIGHT * CELL_DEPTH; + const float_X INV_CELL2_SUM = 1.0 / ( CELL_WIDTH * CELL_WIDTH ) + + 1.0 / ( CELL_HEIGHT * CELL_HEIGHT ) + + 1.0 / ( CELL_DEPTH * CELL_DEPTH ); #elif(SIMDIM==DIM2) - const float_X CELL_VOLUME = CELL_WIDTH * CELL_HEIGHT ; - /* Courant-Friedrichs-Levy-Condition for Field Solver: */ - PMACC_CASSERT_MSG(Courant_Friedrichs_Levy_condition_failure____check_your_gridConfig_param_file, - (PMACC_MIN(CELL_WIDTH,CELL_HEIGHT)/SPEED_OF_LIGHT/DELTA_T)>1.77f); + const float_X CELL_VOLUME = CELL_WIDTH * CELL_HEIGHT; + const float_X INV_CELL2_SUM = 1.0 / ( CELL_WIDTH * CELL_WIDTH ) + + 1.0 / ( CELL_HEIGHT * CELL_HEIGHT ); +#else + const float_X INV_CELL2_SUM = 1.0 / ( CELL_WIDTH * CELL_WIDTH ); #endif + + /* Courant-Friedrichs-Levy-Condition for Yee Field Solver: */ + PMACC_CASSERT_MSG(Courant_Friedrichs_Levy_condition_failure____check_your_gridConfig_param_file, + (SPEED_OF_LIGHT*SPEED_OF_LIGHT*DELTA_T*DELTA_T*INV_CELL2_SUM)<=1.0); } From e905bc9326bdf23c77e5c1aa98cf80daaeb8260d Mon Sep 17 00:00:00 2001 From: Axel Huebl Date: Fri, 25 Apr 2014 16:59:42 +0200 Subject: [PATCH 2/2] Show Optimal CFL in InitialiserController - shows selected and minimum possible ratio for time step - refactor to use log for standard sim output during startup --- .../initialization/InitialiserController.hpp | 65 +++++++------------ 1 file changed, 24 insertions(+), 41 deletions(-) diff --git a/src/picongpu/include/initialization/InitialiserController.hpp b/src/picongpu/include/initialization/InitialiserController.hpp index 3ac4c1a4c6..02753cee96 100644 --- a/src/picongpu/include/initialization/InitialiserController.hpp +++ b/src/picongpu/include/initialization/InitialiserController.hpp @@ -16,8 +16,7 @@ * You should have received a copy of the GNU General Public License * along with PIConGPU. * If not, see . - */ - + */ #pragma once @@ -65,14 +64,14 @@ class InitialiserController : public IInitPlugin { // start simulation using default values log ("Starting simulation from timestep 0"); - + SimStartInitialiser simStartInitialiser; Environment<>::get().DataConnector().initialise(simStartInitialiser, 0); __getTransactionEvent().waitForFinished(); log ("Loading from default values finished"); } - + /** * Load persistent simulation state from \p restartStep */ @@ -81,7 +80,7 @@ class InitialiserController : public IInitPlugin // restart simulation by loading from persistent data // the simulation will start after restartStep log ("Restarting simulation from timestep %1%") % restartStep; - + Environment<>::get().PluginConnector().restartPlugins(restartStep); __getTransactionEvent().waitForFinished(); @@ -95,50 +94,34 @@ class InitialiserController : public IInitPlugin { if (Environment::get().GridController().getGlobalRank() == 0) { - std::cout << "max weighting " << NUM_EL_PER_PARTICLE << std::endl; - - float_X shortestSide = cellSize.x(); - for(uint32_t d=1;d 1.77 ? "<< - shortestSide / SPEED_OF_LIGHT / DELTA_T << std::endl; + log("max weighting %1%") % NUM_EL_PER_PARTICLE; + + log("Courant dt <= %1% ? %2% ") % + (SPEED_OF_LIGHT/math::sqrt(INV_CELL2_SUM)) % + (SPEED_OF_LIGHT * DELTA_T); if (gasProfile::GAS_ENABLED) - std::cout << "omega_pe * dt <= 0.1 ? " << sqrt(GAS_DENSITY * Q_EL / M_EL * Q_EL / EPS0) * DELTA_T << std::endl; + log("omega_pe * dt <= 0.1 ? %1%") % + (sqrt(GAS_DENSITY * Q_EL / M_EL * Q_EL / EPS0) * DELTA_T); if (laserProfile::INIT_TIME > float_X(0.0)) - std::cout << "y-cells per wavelength: " << laserProfile::WAVE_LENGTH / CELL_HEIGHT << std::endl; + log("y-cells per wavelength: %1%") % + (laserProfile::WAVE_LENGTH / CELL_HEIGHT); const int localNrOfCells = cellDescription->getGridLayout().getDataSpaceWithoutGuarding().productOfComponents(); - std::cout << "macro particles per gpu: " - << localNrOfCells * particleInit::NUM_PARTICLES_PER_CELL * (1 + 1 * ENABLE_IONS) << std::endl; - std::cout << "typical macro particle weighting: " << NUM_EL_PER_PARTICLE << std::endl; + log("macro particles per gpu: %1%") % + (localNrOfCells * particleInit::NUM_PARTICLES_PER_CELL * (1 + 1 * ENABLE_IONS)); + log("typical macro particle weighting: %1%") % (NUM_EL_PER_PARTICLE); //const float_X y_R = M_PI * laserProfile::W0 * laserProfile::W0 / laserProfile::WAVE_LENGTH; //rayleigh length (in y-direction) //std::cout << "focus/y_Rayleigh: " << laserProfile::FOCUS_POS / y_R << std::endl; - std::cout << "UNIT_SPEED" << " " << UNIT_SPEED << std::endl; - std::cout << "UNIT_TIME" << " " << UNIT_TIME << std::endl; - std::cout << "UNIT_LENGTH" << " " << UNIT_LENGTH << std::endl; - std::cout << "UNIT_MASS" << " " << UNIT_MASS << std::endl; - std::cout << "UNIT_CHARGE" << " " << UNIT_CHARGE << std::endl; - std::cout << "UNIT_EFIELD" << " " << UNIT_EFIELD << std::endl; - std::cout << "UNIT_BFIELD" << " " << UNIT_BFIELD << std::endl; - std::cout << "UNIT_ENERGY" << " " << UNIT_ENERGY << std::endl; - -#if (ENABLE_HDF5==1) - // check for HDF5 restart capability - typedef typename boost::mpl::find::type itFindFieldE; - typedef typename boost::mpl::find::type itFindFieldB; - typedef typename boost::mpl::end< FileOutputFields>::type itEnd; - const bool restartImpossible = (boost::is_same::value) - || (boost::is_same::value); - if( restartImpossible ) - { - std::cout << "WARNING: HDF5 restart impossible! (dump at least " - << "FieldE and FieldB in hdf5Output.unitless)" - << std::endl; - } -#endif + log("UNIT_SPEED %1%") % UNIT_SPEED; + log("UNIT_TIME %1%") % UNIT_TIME; + log("UNIT_LENGTH %1%") % UNIT_LENGTH; + log("UNIT_MASS %1%") % UNIT_MASS; + log("UNIT_CHARGE %1%") % UNIT_CHARGE; + log("UNIT_EFIELD %1%") % UNIT_EFIELD; + log("UNIT_BFIELD %1%") % UNIT_BFIELD; + log("UNIT_ENERGY %1%") % UNIT_ENERGY; } }