示例#1
0
void on_particle_change()
{
  // EVENT_TRACE(fprintf(stderr, "%d: on_particle_change\n", this_node));
  resort_particles = 1;
  reinit_electrostatics = 1;
  reinit_magnetostatics = 1;
  rebuild_verletlist = 1;

  invalidate_obs();

  /* the particle information is no longer valid */
  freePartCfg();
}
示例#2
0
void on_particle_change()
{
    EVENT_TRACE(fprintf(stderr, "%d: on_particle_change\n", this_node));
    resort_particles = 1;
    reinit_electrostatics = 1;
    reinit_magnetostatics = 1;

#ifdef LB_GPU
    lb_reinit_particles_gpu = 1;
#endif

    invalidate_obs();

    /* the particle information is no longer valid */
    freePartCfg();
}
示例#3
0
void updatePartCfg(int bonds_flag)
{
  int j;

  if(partCfg)
    return;

  partCfg = malloc(n_total_particles*sizeof(Particle));
  if (bonds_flag != WITH_BONDS)
    mpi_get_particles(partCfg, NULL);
  else
    mpi_get_particles(partCfg,&partCfg_bl);

  for(j=0; j<n_total_particles; j++)
    unfold_position(partCfg[j].r.p,partCfg[j].l.i);
  partCfgSorted = 0;
#ifdef VIRTUAL_SITES
  if ((sortPartCfg()==0)||(update_mol_pos_cfg()==0)){
     freePartCfg();
  }
#endif
}
示例#4
0
void on_integration_start()
{
    char *errtext;

    EVENT_TRACE(fprintf(stderr, "%d: on_integration_start\n", this_node));
    INTEG_TRACE(fprintf(stderr,"%d: on_integration_start: reinit_thermo = %d, resort_particles=%d\n",
                        this_node,reinit_thermo,resort_particles));

    /********************************************/
    /* sanity checks                            */
    /********************************************/

    if ( time_step < 0.0 ) {
        errtext = runtime_error(128);
        ERROR_SPRINTF(errtext, "{010 time_step not set} ");
    }
    if ( skin < 0.0 ) {
        errtext = runtime_error(128);
        ERROR_SPRINTF(errtext,"{011 skin not set} ");
    }
    if ( temperature < 0.0 ) {
        errtext = runtime_error(128);
        ERROR_SPRINTF(errtext,"{012 thermostat not initialized} ");
    }

#ifdef NPT
    if (integ_switch == INTEG_METHOD_NPT_ISO) {
        if (nptiso.piston <= 0.0) {
            char *errtext = runtime_error(128);
            ERROR_SPRINTF(errtext,"{014 npt on, but piston mass not set} ");
        }

#ifdef ELECTROSTATICS

        switch(coulomb.method) {
        case COULOMB_NONE:
            break;
#ifdef P3M
        case COULOMB_P3M:
            break;
#endif /*P3M*/
        default: {
            char *errtext = runtime_error(128);
            ERROR_SPRINTF(errtext,"{014 npt only works with P3M} ");
        }
        }
#endif /*ELECTROSTATICS*/

#ifdef DIPOLES

        switch (coulomb.Dmethod) {
        case DIPOLAR_NONE:
            break;
#ifdef DP3M
        case DIPOLAR_P3M:
            break;
#endif
        default: {
            char *errtext = runtime_error(128);
            ERROR_SPRINTF(errtext,"NpT does not work with your dipolar method, please use P3M.");
        }
        }
#endif  /* ifdef DIPOLES */
    }
#endif /*NPT*/

    if (!check_obs_calc_initialized()) return;

#ifdef LB
    if(lattice_switch & LATTICE_LB) {
        if (lbpar.agrid <= 0.0) {
            errtext = runtime_error(128);
            ERROR_SPRINTF(errtext,"{098 Lattice Boltzmann agrid not set} ");
        }
        if (lbpar.tau <= 0.0) {
            errtext = runtime_error(128);
            ERROR_SPRINTF(errtext,"{099 Lattice Boltzmann time step not set} ");
        }
        if (lbpar.rho <= 0.0) {
            errtext = runtime_error(128);
            ERROR_SPRINTF(errtext,"{100 Lattice Boltzmann fluid density not set} ");
        }
        if (lbpar.viscosity <= 0.0) {
            errtext = runtime_error(128);
            ERROR_SPRINTF(errtext,"{101 Lattice Boltzmann fluid viscosity not set} ");
        }
        if (dd.use_vList && skin>=lbpar.agrid/2.0) {
            errtext = runtime_error(128);
            ERROR_SPRINTF(errtext, "{104 LB requires either no Verlet lists or that the skin of the verlet list to be less than half of lattice-Boltzmann grid spacing.} ");
        }
    }
#endif
#ifdef LB_GPU
    if(this_node == 0) {
        if(lattice_switch & LATTICE_LB_GPU) {
            if (lbpar_gpu.agrid < 0.0) {
                errtext = runtime_error(128);
                ERROR_SPRINTF(errtext,"{098 Lattice Boltzmann agrid not set} ");
            }
            if (lbpar_gpu.tau < 0.0) {
                errtext = runtime_error(128);
                ERROR_SPRINTF(errtext,"{099 Lattice Boltzmann time step not set} ");
            }
            if (lbpar_gpu.rho < 0.0) {
                errtext = runtime_error(128);
                ERROR_SPRINTF(errtext,"{100 Lattice Boltzmann fluid density not set} ");
            }
            if (lbpar_gpu.viscosity < 0.0) {
                errtext = runtime_error(128);
                ERROR_SPRINTF(errtext,"{101 Lattice Boltzmann fluid viscosity not set} ");
            }
            if (lb_reinit_particles_gpu) {
                lb_realloc_particles_gpu();
                lb_reinit_particles_gpu = 0;
            }
        }
    }

#endif

#ifdef METADYNAMICS
    meta_init();
#endif

#ifdef REACTIONS
    if(reaction.rate != 0.0) {
        if(max_cut < reaction.range) {
            errtext = runtime_error(128);
            ERROR_SPRINTF(errtext,"{105 Reaction range of %f exceeds maximum cutoff of %f} ", reaction.range, max_cut);
        }
    }
#endif

    /********************************************/
    /* end sanity checks                        */
    /********************************************/


    /* Prepare the thermostat */
    if (reinit_thermo) {
        thermo_init();
        reinit_thermo = 0;
        recalc_forces = 1;
    }

    /* Ensemble preparation: NVT or NPT */
    integrate_ensemble_init();

#ifdef SCAFACOS
    /* initialize Scafacos, set up the system and solver specific parameters, all on
    each node. functions include MPI_Bcast */

    mpi_bcast_coulomb_method();

    switch(coulomb.method) {
    case COULOMB_SCAFACOS_DIRECT:
    case COULOMB_SCAFACOS_EWALD:
    case COULOMB_SCAFACOS_FMM:
    case COULOMB_SCAFACOS_MEMD:
    case COULOMB_SCAFACOS_MMM1D:
    case COULOMB_SCAFACOS_MMM2D:
    case COULOMB_SCAFACOS_P2NFFT:
    case COULOMB_SCAFACOS_P3M:
    case COULOMB_SCAFACOS_PEPC:
    case COULOMB_SCAFACOS_PP3MG:
    case COULOMB_SCAFACOS_VMG: {
        mpi_scafacos_bcast_common_params();
        mpi_scafacos_bcast_solver_specific();
        mpi_scafacos_init();
        mpi_scafacos_common_set();
        mpi_scafacos_solver_specific_set();
        break;
    }
    default:
        break;
    }
    /* tune in order to generate at least defaults for cutoff, transfer the cutoff back
    to Espresso and generate new cell system on each node*/
    switch(coulomb.method) {
    case COULOMB_SCAFACOS_P2NFFT:
        if( scafacos.short_range_flag == 0 ) {
            scafacos_tune();
            recalc_maximal_cutoff();
            cells_on_geometry_change(0);
        }
        break;
    case COULOMB_SCAFACOS_P3M:
        if( scafacos.short_range_flag == 0 ) {
            scafacos_tune();
            recalc_maximal_cutoff();
            cells_on_geometry_change(0);
        }
    default:
        break;
    }
#endif
    /* Update particle and observable information for routines in statistics.c */
    invalidate_obs();
    freePartCfg();

    on_observable_calc();
}
示例#5
0
void on_integration_start()
{
  char *errtext;

  EVENT_TRACE(fprintf(stderr, "%d: on_integration_start\n", this_node));
  INTEG_TRACE(fprintf(stderr,"%d: on_integration_start: reinit_thermo = %d, resort_particles=%d\n",
		      this_node,reinit_thermo,resort_particles));

  /********************************************/
  /* sanity checks                            */
  /********************************************/

  if ( time_step < 0.0 ) {
    errtext = runtime_error(128);
    ERROR_SPRINTF(errtext, "{010 time_step not set} ");
  }
  if ( skin < 0.0 ) {
    errtext = runtime_error(128);
    ERROR_SPRINTF(errtext,"{011 skin not set} ");
  }
  if ( temperature < 0.0 ) {
    errtext = runtime_error(128);
    ERROR_SPRINTF(errtext,"{012 thermostat not initialized} ");
  }
  
#ifdef NPT
  if (integ_switch == INTEG_METHOD_NPT_ISO) {
    if (nptiso.piston <= 0.0) {
      char *errtext = runtime_error(128);
      ERROR_SPRINTF(errtext,"{014 npt on, but piston mass not set} ");
    }
  
#ifdef ELECTROSTATICS

    switch(coulomb.method) {
    case COULOMB_NONE:  break;
#ifdef P3M
    case COULOMB_P3M:   break;
#endif /*P3M*/
    default: {
      char *errtext = runtime_error(128);
      ERROR_SPRINTF(errtext,"{014 npt only works with P3M} ");
    }
    }
#endif /*ELECTROSTATICS*/

#ifdef DIPOLES

    switch (coulomb.Dmethod) {
    case DIPOLAR_NONE: break;
#ifdef DP3M
    case DIPOLAR_P3M: break;
#endif
    default: {
      char *errtext = runtime_error(128);
      ERROR_SPRINTF(errtext,"NpT does not work with your dipolar method, please use P3M.");
    }
    }
#endif  /* ifdef DIPOLES */
  }
#endif /*NPT*/

  if (!check_obs_calc_initialized()) return;

#ifdef LB
  if(lattice_switch & LATTICE_LB) {
    if (lbpar.agrid <= 0.0) {
      errtext = runtime_error(128);
      ERROR_SPRINTF(errtext,"{098 Lattice Boltzmann agrid not set} ");
    }
    if (lbpar.tau <= 0.0) {
      errtext = runtime_error(128);
      ERROR_SPRINTF(errtext,"{099 Lattice Boltzmann time step not set} ");
    }
    if (lbpar.rho <= 0.0) {
      errtext = runtime_error(128);
      ERROR_SPRINTF(errtext,"{100 Lattice Boltzmann fluid density not set} ");
    }
    if (lbpar.viscosity <= 0.0) {
      errtext = runtime_error(128);
      ERROR_SPRINTF(errtext,"{101 Lattice Boltzmann fluid viscosity not set} ");
    }
    if (dd.use_vList && skin>=lbpar.agrid/2.0) {
      errtext = runtime_error(128);
      ERROR_SPRINTF(errtext, "{104 LB requires either no Verlet lists or that the skin of the verlet list to be less than half of lattice-Boltzmann grid spacing.} ");
    }
  }
#endif
#ifdef LB_GPU
if(this_node == 0){
  if(lattice_switch & LATTICE_LB_GPU) {
    if (lbpar_gpu.agrid < 0.0) {
      errtext = runtime_error(128);
      ERROR_SPRINTF(errtext,"{098 Lattice Boltzmann agrid not set} ");
    }
    if (lbpar_gpu.tau < 0.0) {
      errtext = runtime_error(128);
      ERROR_SPRINTF(errtext,"{099 Lattice Boltzmann time step not set} ");
    }
    if (lbpar_gpu.rho < 0.0) {
      errtext = runtime_error(128);
      ERROR_SPRINTF(errtext,"{100 Lattice Boltzmann fluid density not set} ");
    }
    if (lbpar_gpu.viscosity < 0.0) {
      errtext = runtime_error(128);
      ERROR_SPRINTF(errtext,"{101 Lattice Boltzmann fluid viscosity not set} ");
    }
    if (lb_reinit_particles_gpu) {
	lb_realloc_particles_gpu();
	lb_reinit_particles_gpu = 0;
    }
  }
}

#endif

#ifdef METADYNAMICS
  meta_init();
#endif

#ifdef CATALYTIC_REACTIONS
if(reaction.ct_rate != 0.0) {

   if( dd.use_vList == 0 || cell_structure.type != CELL_STRUCTURE_DOMDEC) {
      errtext = runtime_error(128);
      ERROR_SPRINTF(errtext,"{105 The CATALYTIC_REACTIONS feature requires verlet lists and domain decomposition} ");
      check_runtime_errors();
    }

  if(max_cut < reaction.range) {
    errtext = runtime_error(128);
    ERROR_SPRINTF(errtext,"{106 Reaction range of %f exceeds maximum cutoff of %f} ", reaction.range, max_cut);
  }
}
#endif

  /********************************************/
  /* end sanity checks                        */
  /********************************************/


  /* Prepare the thermostat */
  if (reinit_thermo) {
    thermo_init();
    reinit_thermo = 0;
    recalc_forces = 1;
  }

  /* Ensemble preparation: NVT or NPT */
  integrate_ensemble_init();

  /* Update particle and observable information for routines in statistics.c */
  invalidate_obs();
  freePartCfg();

  on_observable_calc();
}
示例#6
0
void on_integration_start()
{
  EVENT_TRACE(fprintf(stderr, "%d: on_integration_start\n", this_node));
  INTEG_TRACE(fprintf(stderr,"%d: on_integration_start: reinit_thermo = %d, resort_particles=%d\n",
		      this_node,reinit_thermo,resort_particles));

  /********************************************/
  /* sanity checks                            */
  /********************************************/

  integrator_sanity_checks();
#ifdef NPT
  integrator_npt_sanity_checks();
#endif
  interactions_sanity_checks();
#ifdef CATALYTIC_REACTIONS
  reactions_sanity_checks();
#endif
#ifdef LB
  if(lattice_switch & LATTICE_LB) {
    lb_sanity_checks();
  }
#endif
#ifdef LB_GPU
  if(lattice_switch & LATTICE_LB_GPU) {
    lb_GPU_sanity_checks();
  }
#endif

  /********************************************/
  /* end sanity checks                        */
  /********************************************/


#ifdef LB_GPU
  if(this_node == 0){
    if (lb_reinit_particles_gpu) {
      lb_realloc_particles_gpu();
      lb_reinit_particles_gpu = 0;
    }
  }
#endif

#ifdef CUDA
  if (reinit_particle_comm_gpu){
    gpu_change_number_of_part_to_comm();
    reinit_particle_comm_gpu = 0;
  }
  MPI_Bcast(gpu_get_global_particle_vars_pointer_host(), sizeof(CUDA_global_part_vars), MPI_BYTE, 0, comm_cart);
#endif

#ifdef METADYNAMICS
  meta_init();
#endif

  /* Prepare the thermostat */
  if (reinit_thermo) {
    thermo_init();
    reinit_thermo = 0;
    recalc_forces = 1;
  }

  /* Ensemble preparation: NVT or NPT */
  integrate_ensemble_init();

  /* Update particle and observable information for routines in statistics.cpp */
  invalidate_obs();
  freePartCfg();

  on_observable_calc();
}
示例#7
0
void on_integration_start()
{
  char *errtext;
  int i;

  EVENT_TRACE(fprintf(stderr, "%d: on_integration_start\n", this_node));
  INTEG_TRACE(fprintf(stderr,"%d: on_integration_start: reinit_thermo = %d, resort_particles=%d\n",
		      this_node,reinit_thermo,resort_particles));

  /********************************************/
  /* sanity checks                            */
  /********************************************/

  if ( time_step < 0.0 ) {
    errtext = runtime_error(128);
    ERROR_SPRINTF(errtext, "{010 time_step not set} ");
  }
  if ( skin < 0.0 ) {
    errtext = runtime_error(128);
    ERROR_SPRINTF(errtext,"{011 skin not set} ");
  }
  if ( temperature < 0.0 ) {
    errtext = runtime_error(128);
    ERROR_SPRINTF(errtext,"{012 thermostat not initialized} ");
  }

  for (i = 0; i < 3; i++)
    if (local_box_l[i] < max_range) {
      errtext = runtime_error(128 + TCL_INTEGER_SPACE);
      ERROR_SPRINTF(errtext,"{013 box_l in direction %d is still too small} ", i);
    }
  
#ifdef NPT
  if (integ_switch == INTEG_METHOD_NPT_ISO) {
    if (nptiso.piston <= 0.0) {
      char *errtext = runtime_error(128);
      ERROR_SPRINTF(errtext,"{014 npt on, but piston mass not set} ");
    }
    if(cell_structure.type!=CELL_STRUCTURE_DOMDEC) {
      char *errtext = runtime_error(128);
      ERROR_SPRINTF(errtext,"{014 npt requires domain decomposition cellsystem} ");
    }
  
#ifdef ELECTROSTATICS

    switch(coulomb.method) {
      case COULOMB_NONE:  break;
#ifdef ELP3M
      case COULOMB_P3M:   break;
#endif /*ELP3M*/
      case COULOMB_EWALD: break;
      default: {
        char *errtext = runtime_error(128);
        ERROR_SPRINTF(errtext,"{014 npt only works with Ewald sum or P3M} ");
      }
    }
#endif /*ELECTROSTATICS*/
  }
  
#endif /*NPT*/

  if (!check_obs_calc_initialized()) return;

#ifdef LB
  if(lattice_switch & LATTICE_LB) {
    if (lbpar.agrid <= 0.0) {
      errtext = runtime_error(128);
      ERROR_SPRINTF(errtext,"{098 Lattice Boltzmann agrid not set} ");
    }
    if (lbpar.tau <= 0.0) {
      errtext = runtime_error(128);
      ERROR_SPRINTF(errtext,"{099 Lattice Boltzmann time step not set} ");
    }
    if (lbpar.rho <= 0.0) {
      errtext = runtime_error(128);
      ERROR_SPRINTF(errtext,"{100 Lattice Boltzmann fluid density not set} ");
    }
    if (lbpar.viscosity <= 0.0) {
      errtext = runtime_error(128);
      ERROR_SPRINTF(errtext,"{101 Lattice Boltzmann fluid viscosity not set} ");
    }
  }
#endif
#ifdef LB_GPU
if(this_node == 0){
  if(lattice_switch & LATTICE_LB_GPU) {
    if (lbpar_gpu.agrid < 0.0) {
      errtext = runtime_error(128);
      ERROR_SPRINTF(errtext,"{098 Lattice Boltzmann agrid not set} ");
    }
    if (lbpar_gpu.tau < 0.0) {
      errtext = runtime_error(128);
      ERROR_SPRINTF(errtext,"{099 Lattice Boltzmann time step not set} ");
    }
    if (lbpar_gpu.rho < 0.0) {
      errtext = runtime_error(128);
      ERROR_SPRINTF(errtext,"{100 Lattice Boltzmann fluid density not set} ");
    }
    if (lbpar_gpu.viscosity < 0.0) {
      errtext = runtime_error(128);
      ERROR_SPRINTF(errtext,"{101 Lattice Boltzmann fluid viscosity not set} ");
    }
    if (lb_reinit_particles_gpu) {
	lb_realloc_particles_gpu();
	lb_reinit_particles_gpu = 0;
    }
  }
}

#endif

#ifdef METADYNAMICS
  meta_init();
#endif

  /********************************************/
  /* end sanity checks                        */
  /********************************************/


  /* Prepare the thermostat */
  if (reinit_thermo) {
    thermo_init();
    reinit_thermo = 0;
    recalc_forces = 1;
  }

  /* Ensemble preparation: NVT or NPT */
  integrate_ensemble_init();

  /* Update particle and observable information for routines in statistics.c */
  invalidate_obs();
  freePartCfg();

  on_observable_calc();
}