Newer
Older
/*----------------------------------------------------------------------
SerialReax - Reax Force Field Simulator
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/>.
----------------------------------------------------------------------*/
Kurt A. O'Hearn
committed
#include "spuremd.h"
Kurt A. O'Hearn
committed
#include "allocate.h"
Kurt A. O'Hearn
committed
#include "box.h"
Kurt A. O'Hearn
committed
#include "control.h"
#include "ffield.h"
Kurt A. O'Hearn
committed
#include "io_tools.h"
Kurt A. O'Hearn
committed
#include "geo_tools.h"
Kurt A. O'Hearn
committed
#include "reset_tools.h"
#include "tool_box.h"
Kurt A. O'Hearn
committed
/* Handles additional entire geometry calculations after
* perturbing atom positions during a simulation step
*/
static void Post_Evolve( reax_system * const system, control_params * const control,
simulation_data * const data, static_storage * const workspace,
Kurt A. O'Hearn
committed
reax_list ** const lists, output_controls * const out_control )
int i;
rvec diff, cross;
/* remove rotational and translational velocity of the center of mass */
Kurt A. O'Hearn
committed
if ( control->ensemble != NVE && control->remove_CoM_vel > 0
Kurt A. O'Hearn
committed
&& data->step % control->remove_CoM_vel == 0 )
Kurt A. O'Hearn
committed
Compute_Center_of_Mass( system, data );
Kurt A. O'Hearn
committed
/* remove translational */
rvec_ScaledAdd( system->atoms[i].v, -1.0, data->vcm );
Kurt A. O'Hearn
committed
/* remove rotational */
rvec_ScaledSum( diff, 1.0, system->atoms[i].x, -1.0, data->xcm );
Kurt A. O'Hearn
committed
rvec_ScaledAdd( system->atoms[i].v, -1.0, cross );
Kurt A. O'Hearn
committed
Kurt A. O'Hearn
committed
if ( control->ensemble == NVE )
{
Compute_Kinetic_Energy( system, data );
}
Kurt A. O'Hearn
committed
if ( (out_control->log_update_freq > 0
&& data->step % out_control->log_update_freq == 0)
Kurt A. O'Hearn
committed
|| (out_control->write_steps > 0
&& data->step % out_control->write_steps == 0) )
{
Kurt A. O'Hearn
committed
Compute_Total_Energy( data );
Kurt A. O'Hearn
committed
}
Kurt A. O'Hearn
committed
if ( control->compute_pressure == TRUE && control->ensemble != sNPT
&& control->ensemble != iNPT && control->ensemble != aNPT )
{
Compute_Pressure_Isotropic( system, control, data, out_control );
}
Kurt A. O'Hearn
committed
/* Parse input files
*
* geo_file: file containing geometry info of the structure to simulate
* ffield_file: file containing force field parameters
* control_file: file containing simulation parameters
*/
static void Read_Input_Files( const char * const geo_file,
const char * const ffield_file, const char * const control_file,
reax_system * const system, control_params * const control,
simulation_data * const data, static_storage * const workspace,
Kurt A. O'Hearn
committed
output_controls * const out_control )
Kurt A. O'Hearn
committed
if ( ffield_file != NULL )
Kurt A. O'Hearn
committed
Read_Force_Field( ffield_file, system, &system->reax_param );
Kurt A. O'Hearn
committed
Set_Control_Defaults( system, control, out_control );
Kurt A. O'Hearn
committed
if ( control_file != NULL )
Kurt A. O'Hearn
committed
{
Kurt A. O'Hearn
committed
Read_Control_File( control_file, system, control, out_control );
Kurt A. O'Hearn
committed
}
Kurt A. O'Hearn
committed
Set_Control_Derived_Values( system, control );
Kurt A. O'Hearn
committed
if ( geo_file != NULL )
Kurt A. O'Hearn
committed
{
Kurt A. O'Hearn
committed
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
if ( control->geo_format == CUSTOM )
{
Read_Geo( geo_file, system, control, data, workspace );
}
else if ( control->geo_format == PDB )
{
Read_PDB( geo_file, system, control, data, workspace );
}
else if ( control->geo_format == BGF )
{
Read_BGF( geo_file, system, control, data, workspace );
}
else if ( control->geo_format == ASCII_RESTART )
{
Read_ASCII_Restart( geo_file, system, control, data, workspace );
control->restart = TRUE;
}
else if ( control->geo_format == BINARY_RESTART )
{
Read_Binary_Restart( geo_file, system, control, data, workspace );
control->restart = TRUE;
}
else
{
fprintf( stderr, "[ERROR] unknown geo file format. terminating!\n" );
exit( INVALID_GEO );
}
Kurt A. O'Hearn
committed
}
Kurt A. O'Hearn
committed
#if defined(DEBUG_FOCUS)
Print_Box( &system->box, stderr );
#endif
}
Kurt A. O'Hearn
committed
/* Allocate top-level data structures and parse input files
* for the first simulation
*
* geo_file: file containing geometry info of the structure to simulate
* ffield_file: file containing force field parameters
* control_file: file containing simulation parameters
*/
Kurt A. O'Hearn
committed
void * setup( const char * const geo_file, const char * const ffield_file,
Kurt A. O'Hearn
committed
const char * const control_file )
int i;
Kurt A. O'Hearn
committed
spuremd_handle *spmd_handle;
/* top-level allocation */
spmd_handle = (spuremd_handle*) smalloc( sizeof(spuremd_handle),
"setup::spmd_handle" );
/* second-level allocations */
spmd_handle->system = smalloc( sizeof(reax_system),
Kurt A. O'Hearn
committed
"Setup::spmd_handle->system" );
Kurt A. O'Hearn
committed
spmd_handle->system->prealloc_allocated = FALSE;
spmd_handle->system->ffield_params_allocated = FALSE;
Kurt A. O'Hearn
committed
spmd_handle->system->g.allocated = FALSE;
spmd_handle->control = smalloc( sizeof(control_params),
Kurt A. O'Hearn
committed
"Setup::spmd_handle->control" );
Kurt A. O'Hearn
committed
spmd_handle->data = smalloc( sizeof(simulation_data),
Kurt A. O'Hearn
committed
"Setup::spmd_handle->data" );
Kurt A. O'Hearn
committed
spmd_handle->workspace = smalloc( sizeof(static_storage),
Kurt A. O'Hearn
committed
"Setup::spmd_handle->workspace" );
Kurt A. O'Hearn
committed
spmd_handle->workspace->H.allocated = FALSE;
spmd_handle->workspace->H_full.allocated = FALSE;
spmd_handle->workspace->H_sp.allocated = FALSE;
spmd_handle->workspace->H_p.allocated = FALSE;
spmd_handle->workspace->H_spar_patt.allocated = FALSE;
spmd_handle->workspace->H_spar_patt_full.allocated = FALSE;
spmd_handle->workspace->H_app_inv.allocated = FALSE;
spmd_handle->workspace->L.allocated = FALSE;
spmd_handle->workspace->U.allocated = FALSE;
spmd_handle->lists = smalloc( sizeof(reax_list *) * LIST_N,
Kurt A. O'Hearn
committed
"Setup::spmd_handle->lists" );
for ( i = 0; i < LIST_N; ++i )
{
spmd_handle->lists[i] = smalloc( sizeof(reax_list),
Loading
Loading full blame...