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
#include <ctype.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
Kurt A. O'Hearn
committed
Compute_Total_Energy( data );
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, int reset )
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
Kurt A. O'Hearn
committed
if ( reset == FALSE || control_file != NULL )
{
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
Kurt A. O'Hearn
committed
if ( reset == FALSE || control_file != NULL )
{
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
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
146
147
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
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
static void Allocate_Top_Level_Structs( spuremd_handle ** handle )
{
int i;
/* top-level allocation */
*handle = smalloc( sizeof(spuremd_handle), "Allocate_Top_Level_Structs::handle" );
/* second-level allocations */
(*handle)->system = smalloc( sizeof(reax_system),
"Allocate_Top_Level_Structs::handle->system" );
(*handle)->control = smalloc( sizeof(control_params),
"Allocate_Top_Level_Structs::handle->control" );
(*handle)->data = smalloc( sizeof(simulation_data),
"Allocate_Top_Level_Structs::handle->data" );
(*handle)->workspace = smalloc( sizeof(static_storage),
"Allocate_Top_Level_Structs::handle->workspace" );
(*handle)->lists = smalloc( sizeof(reax_list *) * LIST_N,
"Allocate_Top_Level_Structs::handle->lists" );
for ( i = 0; i < LIST_N; ++i )
{
(*handle)->lists[i] = smalloc( sizeof(reax_list),
"Allocate_Top_Level_Structs::handle->lists[i]" );
}
(*handle)->out_control = smalloc( sizeof(output_controls),
"Allocate_Top_Level_Structs::handle->out_control" );
}
static void Initialize_Top_Level_Structs( spuremd_handle * handle )
{
int i;
/* top-level initializations */
handle->output_enabled = TRUE;
handle->realloc = TRUE;
handle->callback = NULL;
handle->data->sim_id = 0;
/* second-level initializations */
handle->system->prealloc_allocated = FALSE;
handle->system->ffield_params_allocated = FALSE;
Loading
Loading full blame...