Skip to content
Snippets Groups Projects
init_md.c 36.1 KiB
Newer Older
Kurt A. O'Hearn's avatar
Kurt A. O'Hearn committed
/*----------------------------------------------------------------------
  PuReMD - Purdue ReaxFF Molecular Dynamics Program
Kurt A. O'Hearn's avatar
Kurt A. O'Hearn committed

Kurt A. O'Hearn's avatar
Kurt A. O'Hearn committed
  Copyright (2010) Purdue University
  Hasan Metin Aktulga, haktulga@cs.purdue.edu
  Joseph Fogarty, jcfogart@mail.usf.edu
  Sagar Pandit, pandit@usf.edu
  Ananth Y Grama, ayg@cs.purdue.edu

  This program is free software; you can redistribute it and/or
  modify it under the terms of the GNU General Public License as
Kurt A. O'Hearn's avatar
Kurt A. O'Hearn committed
  published by the Free Software Foundation; either version 2 of
Kurt A. O'Hearn's avatar
Kurt A. O'Hearn committed
  the License, or (at your option) any later version.
Kurt A. O'Hearn's avatar
Kurt A. O'Hearn committed

Kurt A. O'Hearn's avatar
Kurt A. O'Hearn committed
  This program is distributed in the hope that it will be useful,
  but WITHOUT ANY WARRANTY; without even the implied warranty of
Kurt A. O'Hearn's avatar
Kurt A. O'Hearn committed
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
Kurt A. O'Hearn's avatar
Kurt A. O'Hearn committed
  See the GNU General Public License for more details:
  <http://www.gnu.org/licenses/>.
  ----------------------------------------------------------------------*/

#if (defined(HAVE_CONFIG_H) && !defined(__CONFIG_H_))
  #define __CONFIG_H_
  #include "../../common/include/config.h"
#endif
Kurt A. O'Hearn's avatar
Kurt A. O'Hearn committed
#if defined(PURE_REAX)
  #include "allocate.h"
  #include "box.h"
  #include "comm_tools.h"
  #include "forces.h"
  #include "grid.h"
  #include "integrate.h"
  #include "io_tools.h"
  #include "list.h"
  #include "lookup.h"
  #include "neighbors.h"
  #include "random.h"
  #include "reset_tools.h"
  #include "system_props.h"
  #include "tool_box.h"
  #include "vector.h"
Kurt A. O'Hearn's avatar
Kurt A. O'Hearn committed
#elif defined(LAMMPS_REAX)
  #include "reax_allocate.h"
  #include "reax_forces.h"
  #include "reax_io_tools.h"
  #include "reax_list.h"
  #include "reax_lookup.h"
  #include "reax_reset_tools.h"
  #include "reax_system_props.h"
  #include "reax_tool_box.h"
  #include "reax_vector.h"
Kurt A. O'Hearn's avatar
Kurt A. O'Hearn committed
#endif

Kurt A. O'Hearn's avatar
Kurt A. O'Hearn committed

#if defined(PURE_REAX)
/************************ initialize system ************************/
static void Reposition_Atoms( reax_system * const system, control_params * const control,
        simulation_data * const data, mpi_datatypes * const mpi_data )
Kurt A. O'Hearn's avatar
Kurt A. O'Hearn committed
{
Kurt A. O'Hearn's avatar
Kurt A. O'Hearn committed

    /* reposition atoms */
    /* fit atoms to periodic box */
    if ( control->reposition_atoms == 0 )
Kurt A. O'Hearn's avatar
Kurt A. O'Hearn committed
    {
        rvec_MakeZero( dx );
    }
    /* put center of mass to center */
    else if ( control->reposition_atoms == 1 )
Kurt A. O'Hearn's avatar
Kurt A. O'Hearn committed
    {
        rvec_Scale( dx, 0.5, system->big_box.box_norms );
Kurt A. O'Hearn's avatar
Kurt A. O'Hearn committed
    }
    /* put center of mass to origin */
    else if ( control->reposition_atoms == 2 )
Kurt A. O'Hearn's avatar
Kurt A. O'Hearn committed
    {
Kurt A. O'Hearn's avatar
Kurt A. O'Hearn committed
    }
    else
    {
        fprintf( stderr, "[ERROR] p%d: Reposition_Atoms: invalid option (%d)\n",
              system->my_rank, control->reposition_atoms );
        MPI_Abort( MPI_COMM_WORLD,  INVALID_INPUT );
Kurt A. O'Hearn's avatar
Kurt A. O'Hearn committed
    }

    for ( i = 0; i < system->n; ++i )
//        Inc_on_T3_Gen( system->my_atoms[i].x, dx, &system->big_box );
Kurt A. O'Hearn's avatar
Kurt A. O'Hearn committed
        rvec_Add( system->my_atoms[i].x, dx );
void Generate_Initial_Velocities( reax_system * const system, real T )
Kurt A. O'Hearn's avatar
Kurt A. O'Hearn committed
{
Kurt A. O'Hearn's avatar
Kurt A. O'Hearn committed
    int i;
    real m, scale, norm;

    if ( T <= 0.1 )
    {
        for ( i = 0; i < system->n; i++ )
Kurt A. O'Hearn's avatar
Kurt A. O'Hearn committed
            rvec_MakeZero( system->my_atoms[i].v );
Kurt A. O'Hearn's avatar
Kurt A. O'Hearn committed
    }
    else
    {
Kurt A. O'Hearn's avatar
Kurt A. O'Hearn committed

        for ( i = 0; i < system->n; i++ )
        {
            rvec_Random( system->my_atoms[i].v );

            norm = rvec_Norm_Sqr( system->my_atoms[i].v );
            m = system->reax_param.sbp[ system->my_atoms[i].type ].mass;
            scale = SQRT( m * norm / (3.0 * K_B * T) );

            rvec_Scale( system->my_atoms[i].v, 1.0 / scale, system->my_atoms[i].v );
Kurt A. O'Hearn's avatar
Kurt A. O'Hearn committed
        }
void Init_System( reax_system * const system, control_params * const control,
        simulation_data * const data, storage * const workspace,
        mpi_datatypes * const mpi_data )
Kurt A. O'Hearn's avatar
Kurt A. O'Hearn committed
{
Kurt A. O'Hearn's avatar
Kurt A. O'Hearn committed
    int i;
    reax_atom *atom;

    Setup_New_Grid( system, control, MPI_COMM_WORLD );
    /* since all processors read in all atoms and select their local atoms
     * intially, no local atoms comm needed and just bin local atoms */
    Bin_My_Atoms( system, workspace );
Kurt A. O'Hearn's avatar
Kurt A. O'Hearn committed
    Reorder_My_Atoms( system, workspace );

    system->N = SendRecv( system, mpi_data, mpi_data->boundary_atom_type,
            &Count_Boundary_Atoms, &Sort_Boundary_Atoms,
            &Unpack_Exchange_Message, TRUE );
    system->total_cap = MAX( (int) CEIL( system->N * SAFE_ZONE ), MIN_CAP );

Kurt A. O'Hearn's avatar
Kurt A. O'Hearn committed
    Bin_Boundary_Atoms( system );
#if defined(NEUTRAL_TERRITORY)
    Estimate_NT_Atoms( system, mpi_data );
#endif
            if ( system->reax_param.sbp[ atom->type ].p_hbond == H_ATOM )
                atom->Hindex = system->numH++;
    system->far_nbrs = smalloc( sizeof(int) * system->total_cap,
    system->max_far_nbrs = smalloc( sizeof(int) * system->total_cap,
    system->bonds = smalloc( sizeof(int) * system->total_cap,
    system->max_bonds = smalloc( sizeof(int) * system->total_cap,
    system->hbonds = smalloc( sizeof(int) * system->total_cap,
    system->max_hbonds = smalloc( sizeof(int) * system->total_cap,
    system->cm_entries = smalloc( sizeof(int) * system->local_cap,
    system->max_cm_entries = smalloc( sizeof(int) * system->local_cap,
            "Init_System::max_cm_entries->max_hbonds" );
Kurt A. O'Hearn's avatar
Kurt A. O'Hearn committed
#if defined(DEBUG_FOCUS)
    fprintf( stderr, "p%d: n=%d, local_cap=%d\n",
Kurt A. O'Hearn's avatar
Kurt A. O'Hearn committed
             system->my_rank, system->n, system->local_cap );
Loading
Loading full blame...