Newer
Older
/*----------------------------------------------------------------------
PuReMD - Purdue ReaxFF Molecular Dynamics Program
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
published by the Free Software Foundation; either version 2 of
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
See the GNU General Public License for more details:
<http://www.gnu.org/licenses/>.
----------------------------------------------------------------------*/
#include "reax_types.h"
Kurt A. O'Hearn
committed
#include "init_md.h"
#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
committed
#include "reax_init_md.h"
#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"
#endif
#if defined(PURE_REAX)
/************************ initialize system ************************/
static int Reposition_Atoms( reax_system * const system, control_params * const control,
simulation_data * const data, mpi_datatypes * const mpi_data, char * const msg )
Kurt A. O'Hearn
committed
int i;
rvec dx;
Kurt A. O'Hearn
committed
/* fit atoms to periodic box */
if ( control->reposition_atoms == 0 )
Kurt A. O'Hearn
committed
/* put center of mass to center */
else if ( control->reposition_atoms == 1 )
{
rvec_Scale( dx, 0.5, system->big_box.box_norms );
Kurt A. O'Hearn
committed
rvec_ScaledAdd( dx, -1.0, data->xcm );
Kurt A. O'Hearn
committed
/* put center of mass to origin */
else if ( control->reposition_atoms == 2 )
Kurt A. O'Hearn
committed
rvec_Scale( dx, -1.0, data->xcm );
Kurt A. O'Hearn
committed
strcpy( msg, "[ERROR] reposition_atoms: invalid option" );
return FAILURE;
}
for ( i = 0; i < system->n; ++i )
Kurt A. O'Hearn
committed
{
Kurt A. O'Hearn
committed
// Inc_on_T3_Gen( system->my_atoms[i].x, dx, &system->big_box );
Kurt A. O'Hearn
committed
}
void Generate_Initial_Velocities( reax_system * const system, real T )
int i;
real m, scale, norm;
if ( T <= 0.1 )
{
for ( i = 0; i < system->n; i++ )
Kurt A. O'Hearn
committed
{
Kurt A. O'Hearn
committed
}
Kurt A. O'Hearn
committed
Randomize( );
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) );
Kurt A. O'Hearn
committed
rvec_Scale( system->my_atoms[i].v, 1.0 / scale, system->my_atoms[i].v );
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
committed
Setup_New_Grid( system, control, MPI_COMM_WORLD );
Kurt A. O'Hearn
committed
Kurt A. O'Hearn
committed
/* 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
committed
system->N = SendRecv( system, mpi_data, mpi_data->boundary_atom_type,
&Count_Boundary_Atoms, &Sort_Boundary_Atoms,
&Unpack_Exchange_Message, TRUE );
Kurt A. O'Hearn
committed
Kurt A. O'Hearn
committed
system->total_cap = MAX( (int) CEIL( system->N * SAFE_ZONE ), MIN_CAP );
Kurt A. O'Hearn
committed
#if defined(NEUTRAL_TERRITORY)
Estimate_NT_Atoms( system, mpi_data );
#endif
Kurt A. O'Hearn
committed
/* estimate numH */
system->numH = 0;
Kurt A. O'Hearn
committed
if ( control->hbond_cut > 0.0 )
{
Kurt A. O'Hearn
committed
for ( i = 0; i < system->N; ++i )
Kurt A. O'Hearn
committed
atom = &system->my_atoms[i];
Kurt A. O'Hearn
committed
if ( system->reax_param.sbp[ atom->type ].p_hbond == H_ATOM )
Kurt A. O'Hearn
committed
{
atom->Hindex = system->numH++;
Kurt A. O'Hearn
committed
}
else
{
atom->Hindex = -1;
}
Kurt A. O'Hearn
committed
}
Kurt A. O'Hearn
committed
Kurt A. O'Hearn
committed
/* list management */
Kurt A. O'Hearn
committed
system->far_nbrs = smalloc( sizeof(int) * system->total_cap,
Kurt A. O'Hearn
committed
"Init_System::system->far_nbrs" );
Kurt A. O'Hearn
committed
system->max_far_nbrs = smalloc( sizeof(int) * system->total_cap,
Kurt A. O'Hearn
committed
"Init_System::system->max_far_nbrs" );
Kurt A. O'Hearn
committed
Kurt A. O'Hearn
committed
system->bonds = smalloc( sizeof(int) * system->total_cap,
Kurt A. O'Hearn
committed
"Init_System::system->bonds" );
Kurt A. O'Hearn
committed
system->max_bonds = smalloc( sizeof(int) * system->total_cap,
Kurt A. O'Hearn
committed
"Init_System::system->max_bonds" );
Kurt A. O'Hearn
committed
Kurt A. O'Hearn
committed
system->hbonds = smalloc( sizeof(int) * system->total_cap,
Kurt A. O'Hearn
committed
"Init_System::system->hbonds" );
Kurt A. O'Hearn
committed
system->max_hbonds = smalloc( sizeof(int) * system->total_cap,
Kurt A. O'Hearn
committed
"Init_System::system->max_hbonds" );
Kurt A. O'Hearn
committed
Kurt A. O'Hearn
committed
system->cm_entries = smalloc( sizeof(int) * system->local_cap,
Kurt A. O'Hearn
committed
"Init_System::system->cm_entries" );
Kurt A. O'Hearn
committed
system->max_cm_entries = smalloc( sizeof(int) * system->local_cap,
Kurt A. O'Hearn
committed
"Init_System::max_cm_entries->max_hbonds" );
Kurt A. O'Hearn
committed
Kurt A. O'Hearn
committed
fprintf( stderr, "p%d: n=%d, local_cap=%d\n",
Kurt A. O'Hearn
committed
fprintf( stderr, "p%d: N=%d, total_cap=%d\n",
Kurt A. O'Hearn
committed
fprintf( stderr, "p%d: numH=%d\n",
system->my_rank, system->numH );
Loading
Loading full blame...