Newer
Older
Kurt A. O'Hearn
committed
&spmd_handle->system->box );
for ( i = 0; i < spmd_handle->system->N_qm; ++i )
{
Kurt A. O'Hearn
committed
x[0] = qm_pos[3 * i];
x[1] = qm_pos[3 * i + 1];
x[2] = qm_pos[3 * i + 2];
Kurt A. O'Hearn
committed
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
Fit_to_Periodic_Box( &spmd_handle->system->box, x );
spmd_handle->workspace->orig_id[i] = i + 1;
// spmd_handle->system->atoms[i].type = Get_Atom_Type( &system->reax_param,
// element, sizeof(element) );
spmd_handle->system->atoms[i].type = qm_types[i];
// strncpy( spmd_handle->system->atoms[i].name, atom_name,
// sizeof(spmd_handle->system->atoms[i].name) - 1 );
// spmd_handle->system->atoms[i].name[sizeof(spmd_handle->system->atoms[i].name) - 1] = '\0';
rvec_Copy( spmd_handle->system->atoms[i].x, x );
rvec_MakeZero( spmd_handle->system->atoms[i].v );
rvec_MakeZero( spmd_handle->system->atoms[i].f );
spmd_handle->system->atoms[i].q = 0.0;
spmd_handle->system->atoms[i].q_init = 0.0;
spmd_handle->system->atoms[i].qmmm_mask = TRUE;
}
for ( i = spmd_handle->system->N_qm; i < spmd_handle->system->N; ++i )
{
Kurt A. O'Hearn
committed
x[0] = mm_pos[3 * (i - spmd_handle->system->N_qm)];
x[1] = mm_pos[3 * (i - spmd_handle->system->N_qm) + 1];
x[2] = mm_pos[3 * (i - spmd_handle->system->N_qm) + 2];
Kurt A. O'Hearn
committed
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
Fit_to_Periodic_Box( &spmd_handle->system->box, x );
spmd_handle->workspace->orig_id[i] = i + 1;
// spmd_handle->system->atoms[i].type = Get_Atom_Type( &system->reax_param,
// element, sizeof(element) );
spmd_handle->system->atoms[i].type = mm_types[i - spmd_handle->system->N_qm];
// strncpy( spmd_handle->system->atoms[i].name, atom_name,
// sizeof(spmd_handle->system->atoms[i].name) - 1 );
// spmd_handle->system->atoms[i].name[sizeof(spmd_handle->system->atoms[i].name) - 1] = '\0';
rvec_Copy( spmd_handle->system->atoms[i].x, x );
rvec_MakeZero( spmd_handle->system->atoms[i].v );
rvec_MakeZero( spmd_handle->system->atoms[i].f );
spmd_handle->system->atoms[i].q = mm_q[i - spmd_handle->system->N_qm];
spmd_handle->system->atoms[i].q_init = mm_q[i - spmd_handle->system->N_qm];
spmd_handle->system->atoms[i].qmmm_mask = FALSE;
}
spmd_handle->system->N_max = (int) CEIL( SAFE_ZONE * spmd_handle->system->N );
return (void *) spmd_handle;
}
/* Reset for the next simulation by parsing input files and triggering
* reallocation if more space is needed
*
* handle: pointer to wrapper struct with top-level data structures
* qm_num_atoms: num. atoms in the QM region
* qm_types: element types for QM atoms
Kurt A. O'Hearn
committed
* qm_pos: coordinates of QM atom positions (consecutively arranged), in Angstroms
Kurt A. O'Hearn
committed
* mm_num_atoms: num. atoms in the MM region
* mm_types: element types for MM atoms
Kurt A. O'Hearn
committed
* mm_pos: coordinates of MM atom positions (consecutively arranged), in Angstroms
Kurt A. O'Hearn
committed
* mm_q: charge of MM atom, in Coulombs
* sim_box_info: simulation box information, where the entries are
* - box length per dimension (3 entries)
* - angles per dimension (3 entries)
* ffield_file: file containing force field parameters
* control_file: file containing simulation parameters
*
* returns: SPUREMD_SUCCESS upon success, SPUREMD_FAILURE otherwise
*/
int reset_qmmm( const void * const handle,
int qm_num_atoms, const int * const qm_types,
Kurt A. O'Hearn
committed
const double * const qm_pos,
Kurt A. O'Hearn
committed
int mm_num_atoms, const int * const mm_types,
Kurt A. O'Hearn
committed
const double * const mm_pos, const double * const mm_q,
Kurt A. O'Hearn
committed
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
const double * const sim_box_info,
const char * const ffield_file, const char * const control_file )
{
int i, ret;
rvec x;
spuremd_handle *spmd_handle;
ret = SPUREMD_FAILURE;
if ( handle != NULL )
{
spmd_handle = (spuremd_handle*) handle;
/* close files used in previous simulation */
if ( spmd_handle->output_enabled == TRUE )
{
Finalize_Out_Controls( spmd_handle->system, spmd_handle->control,
spmd_handle->workspace, spmd_handle->out_control );
}
spmd_handle->realloc = FALSE;
spmd_handle->data->sim_id++;
Kurt A. O'Hearn
committed
Read_Input_Files( NULL, ffield_file, control_file,
spmd_handle->system, spmd_handle->control,
spmd_handle->data, spmd_handle->workspace,
spmd_handle->out_control, TRUE );
Kurt A. O'Hearn
committed
spmd_handle->system->N_qm = qm_num_atoms;
spmd_handle->system->N_mm = mm_num_atoms;
spmd_handle->system->N = spmd_handle->system->N_qm + spmd_handle->system->N_mm;
Kurt A. O'Hearn
committed
if ( spmd_handle->system->prealloc_allocated == FALSE
|| spmd_handle->system->N > spmd_handle->system->N_max )
{
PreAllocate_Space( spmd_handle->system, spmd_handle->control,
spmd_handle->workspace, (int) CEIL( SAFE_ZONE * spmd_handle->system->N ) );
}
Kurt A. O'Hearn
committed
Setup_Box( sim_box_info[0], sim_box_info[1], sim_box_info[2],
sim_box_info[3], sim_box_info[4], sim_box_info[5],
&spmd_handle->system->box );
for ( i = 0; i < spmd_handle->system->N_qm; ++i )
{
Kurt A. O'Hearn
committed
x[0] = qm_pos[3 * i];
x[1] = qm_pos[3 * i + 1];
x[2] = qm_pos[3 * i + 2];
Kurt A. O'Hearn
committed
Fit_to_Periodic_Box( &spmd_handle->system->box, x );
spmd_handle->workspace->orig_id[i] = i + 1;
// spmd_handle->system->atoms[i].type = Get_Atom_Type( &system->reax_param,
// element, sizeof(element) );
spmd_handle->system->atoms[i].type = qm_types[i];
// strncpy( spmd_handle->system->atoms[i].name, atom_name,
// sizeof(spmd_handle->system->atoms[i].name) - 1 );
// spmd_handle->system->atoms[i].name[sizeof(spmd_handle->system->atoms[i].name) - 1] = '\0';
rvec_Copy( spmd_handle->system->atoms[i].x, x );
rvec_MakeZero( spmd_handle->system->atoms[i].v );
rvec_MakeZero( spmd_handle->system->atoms[i].f );
spmd_handle->system->atoms[i].q = 0.0;
spmd_handle->system->atoms[i].qmmm_mask = TRUE;
}
for ( i = spmd_handle->system->N_qm; i < spmd_handle->system->N; ++i )
{
Kurt A. O'Hearn
committed
x[0] = mm_pos[3 * (i - spmd_handle->system->N_qm)];
x[1] = mm_pos[3 * (i - spmd_handle->system->N_qm) + 1];
x[2] = mm_pos[3 * (i - spmd_handle->system->N_qm) + 2];
Kurt A. O'Hearn
committed
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
Fit_to_Periodic_Box( &spmd_handle->system->box, x );
spmd_handle->workspace->orig_id[i] = i + 1;
// spmd_handle->system->atoms[i].type = Get_Atom_Type( &system->reax_param,
// element, sizeof(element) );
spmd_handle->system->atoms[i].type = mm_types[i - spmd_handle->system->N_qm];
// strncpy( spmd_handle->system->atoms[i].name, atom_name,
// sizeof(spmd_handle->system->atoms[i].name) - 1 );
// spmd_handle->system->atoms[i].name[sizeof(spmd_handle->system->atoms[i].name) - 1] = '\0';
rvec_Copy( spmd_handle->system->atoms[i].x, x );
rvec_MakeZero( spmd_handle->system->atoms[i].v );
rvec_MakeZero( spmd_handle->system->atoms[i].f );
spmd_handle->system->atoms[i].q = mm_q[i - spmd_handle->system->N_qm];
spmd_handle->system->atoms[i].qmmm_mask = FALSE;
}
if ( spmd_handle->system->N > spmd_handle->system->N_max )
{
/* deallocate everything which needs more space
* (i.e., structures whose space is a function of the number of atoms),
* except for data structures allocated while parsing input files */
Finalize( spmd_handle->system, spmd_handle->control, spmd_handle->data,
spmd_handle->workspace, spmd_handle->lists, spmd_handle->out_control,
spmd_handle->output_enabled, TRUE );
spmd_handle->system->N_max = (int) CEIL( SAFE_ZONE * spmd_handle->system->N );
spmd_handle->realloc = TRUE;
}
ret = SPUREMD_SUCCESS;
}
return ret;
}
/* Getter for atom positions in QMMM mode
*
* handle: pointer to wrapper struct with top-level data structures
Kurt A. O'Hearn
committed
* qm_pos: coordinates of QM atom positions (consecutively arranged), in Angstroms (allocated by caller)
* mm_pos: coordinates of MM atom positions (consecutively arranged), in Angstroms (allocated by caller)
Kurt A. O'Hearn
committed
*
* returns: SPUREMD_SUCCESS upon success, SPUREMD_FAILURE otherwise
*/
Kurt A. O'Hearn
committed
int get_atom_positions_qmmm( const void * const handle, double * const qm_pos,
double * const mm_pos )
Kurt A. O'Hearn
committed
{
int i, ret;
spuremd_handle *spmd_handle;
ret = SPUREMD_FAILURE;
if ( handle != NULL )
{
spmd_handle = (spuremd_handle*) handle;
Kurt A. O'Hearn
committed
if ( qm_pos != NULL )
Kurt A. O'Hearn
committed
{
Kurt A. O'Hearn
committed
for ( i = 0; i < spmd_handle->system->N_qm; ++i )
{
qm_pos[3 * i] = spmd_handle->system->atoms[i].x[0];
qm_pos[3 * i + 1] = spmd_handle->system->atoms[i].x[1];
qm_pos[3 * i + 2] = spmd_handle->system->atoms[i].x[2];
}
Kurt A. O'Hearn
committed
}
Kurt A. O'Hearn
committed
if ( mm_pos != NULL )
Kurt A. O'Hearn
committed
{
Kurt A. O'Hearn
committed
for ( i = spmd_handle->system->N_qm; i < spmd_handle->system->N; ++i )
{
mm_pos[3 * (i - spmd_handle->system->N_qm)] = spmd_handle->system->atoms[i].x[0];
mm_pos[3 * (i - spmd_handle->system->N_qm) + 1] = spmd_handle->system->atoms[i].x[1];
mm_pos[3 * (i - spmd_handle->system->N_qm) + 2] = spmd_handle->system->atoms[i].x[2];
}
Kurt A. O'Hearn
committed
}
ret = SPUREMD_SUCCESS;
}
return ret;
}
/* Getter for atom velocities in QMMM mode
*
* handle: pointer to wrapper struct with top-level data structures
Kurt A. O'Hearn
committed
* qm_vel: coordinates of QM atom velocities (consecutively arranged), in Angstroms / ps (allocated by caller)
* mm_vel: coordinates of MM atom velocities (consecutively arranged), in Angstroms / ps (allocated by caller)
Kurt A. O'Hearn
committed
*
* returns: SPUREMD_SUCCESS upon success, SPUREMD_FAILURE otherwise
*/
Kurt A. O'Hearn
committed
int get_atom_velocities_qmmm( const void * const handle, double * const qm_vel,
double * const mm_vel )
Kurt A. O'Hearn
committed
{
int i, ret;
spuremd_handle *spmd_handle;
ret = SPUREMD_FAILURE;
if ( handle != NULL )
{
spmd_handle = (spuremd_handle*) handle;
Kurt A. O'Hearn
committed
if ( qm_vel != NULL )
Kurt A. O'Hearn
committed
{
Kurt A. O'Hearn
committed
for ( i = 0; i < spmd_handle->system->N_qm; ++i )
{
qm_vel[3 * i] = spmd_handle->system->atoms[i].v[0];
qm_vel[3 * i + 1] = spmd_handle->system->atoms[i].v[1];
qm_vel[3 * i + 2] = spmd_handle->system->atoms[i].v[2];
}
Kurt A. O'Hearn
committed
}
Kurt A. O'Hearn
committed
if ( mm_vel != NULL )
Kurt A. O'Hearn
committed
{
Kurt A. O'Hearn
committed
for ( i = spmd_handle->system->N_qm; i < spmd_handle->system->N; ++i )
{
mm_vel[3 * (i - spmd_handle->system->N_qm)] = spmd_handle->system->atoms[i].v[0];
mm_vel[3 * (i - spmd_handle->system->N_qm) + 1] = spmd_handle->system->atoms[i].v[1];
mm_vel[3 * (i - spmd_handle->system->N_qm) + 2] = spmd_handle->system->atoms[i].v[2];
}
Kurt A. O'Hearn
committed
}
ret = SPUREMD_SUCCESS;
}
return ret;
}
/* Getter for atom forces in QMMM mode
*
* handle: pointer to wrapper struct with top-level data structures
Kurt A. O'Hearn
committed
* qm_f: coordinates of QM atom forces (consecutively arranged), in Angstroms * Daltons / ps^2 (allocated by caller)
* mm_f: coordinates of MM atom forces (consecutively arranged), in Angstroms * Daltons / ps^2 (allocated by caller)
Kurt A. O'Hearn
committed
*
* returns: SPUREMD_SUCCESS upon success, SPUREMD_FAILURE otherwise
*/
Kurt A. O'Hearn
committed
int get_atom_forces_qmmm( const void * const handle, double * const qm_f,
double * const mm_f )
Kurt A. O'Hearn
committed
{
int i, ret;
spuremd_handle *spmd_handle;
ret = SPUREMD_FAILURE;
if ( handle != NULL )
{
spmd_handle = (spuremd_handle*) handle;
Kurt A. O'Hearn
committed
if ( qm_f != NULL )
Kurt A. O'Hearn
committed
{
Kurt A. O'Hearn
committed
for ( i = 0; i < spmd_handle->system->N_qm; ++i )
{
qm_f[3 * i] = spmd_handle->system->atoms[i].f[0];
qm_f[3 * i + 1] = spmd_handle->system->atoms[i].f[1];
qm_f[3 * i + 2] = spmd_handle->system->atoms[i].f[2];
}
Kurt A. O'Hearn
committed
}
Kurt A. O'Hearn
committed
if ( mm_f != NULL )
Kurt A. O'Hearn
committed
{
Kurt A. O'Hearn
committed
for ( i = spmd_handle->system->N_qm; i < spmd_handle->system->N; ++i )
{
mm_f[3 * (i - spmd_handle->system->N_qm)] = spmd_handle->system->atoms[i].f[0];
mm_f[3 * (i - spmd_handle->system->N_qm) + 1] = spmd_handle->system->atoms[i].f[1];
mm_f[3 * (i - spmd_handle->system->N_qm) + 2] = spmd_handle->system->atoms[i].f[2];
}
Kurt A. O'Hearn
committed
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
}
ret = SPUREMD_SUCCESS;
}
return ret;
}
/* Getter for atom charges in QMMM mode
*
* handle: pointer to wrapper struct with top-level data structures
* qm_q: QM atom charges, in Coulombs (allocated by caller)
* mm_q: MM atom charges, in Coulombs (allocated by caller)
*
* returns: SPUREMD_SUCCESS upon success, SPUREMD_FAILURE otherwise
*/
int get_atom_charges_qmmm( const void * const handle, double * const qm_q,
double * const mm_q )
{
int i, ret;
spuremd_handle *spmd_handle;
ret = SPUREMD_FAILURE;
if ( handle != NULL )
{
spmd_handle = (spuremd_handle*) handle;
Kurt A. O'Hearn
committed
if ( qm_q != NULL )
Kurt A. O'Hearn
committed
{
Kurt A. O'Hearn
committed
for ( i = 0; i < spmd_handle->system->N_qm; ++i )
{
qm_q[i] = spmd_handle->system->atoms[i].q;
}
Kurt A. O'Hearn
committed
}
Kurt A. O'Hearn
committed
if ( mm_q != NULL )
Kurt A. O'Hearn
committed
{
Kurt A. O'Hearn
committed
for ( i = spmd_handle->system->N_qm; i < spmd_handle->system->N; ++i )
{
mm_q[i - spmd_handle->system->N_qm] = spmd_handle->system->atoms[i].q;
}
Kurt A. O'Hearn
committed
}
ret = SPUREMD_SUCCESS;
}
return ret;
}
#endif
Kurt A. O'Hearn
committed
#if defined(QMMM_FORTRAN_AMBER)
Kurt A. O'Hearn
committed
/* Allocate top-level data structures and parse input files
* for the first simulation
*
* handle: pointer to wrapper struct with top-level data structures
* qm_num_atoms: num. atoms in the QM region
* qm_types: element types for QM atoms
Kurt A. O'Hearn
committed
* qm_pos: coordinates of QM atom positions (consecutively arranged), in Angstroms
Kurt A. O'Hearn
committed
* mm_num_atoms: num. atoms in the MM region
* mm_types: element types for MM atoms
Kurt A. O'Hearn
committed
* mm_pos_q: coordinates and charges of MM atom positions (consecutively arranged), in Angstroms / Coulombs
Kurt A. O'Hearn
committed
* sim_box_info: simulation box information, where the entries are
* - box length per dimension (3 entries)
* - angles per dimension (3 entries)
* ffield_file: file containing force field parameters
* control_file: file containing simulation parameters
*/
Kurt A. O'Hearn
committed
void setup_qmmm_( void ** handle, const int * const qm_num_atoms,
const int * const qm_types, const double * const qm_pos,
const int * const mm_num_atoms, const int * const mm_types,
const double * const mm_pos_q, const double * const sim_box_info,
const char * const ffield_file, const char * const control_file )
Kurt A. O'Hearn
committed
{
Kurt A. O'Hearn
committed
int i;
// char atom_name[9];
rvec x;
spuremd_handle *spmd_handle;
Kurt A. O'Hearn
committed
Allocate_Top_Level_Structs( &spmd_handle );
Initialize_Top_Level_Structs( spmd_handle );
Kurt A. O'Hearn
committed
Kurt A. O'Hearn
committed
/* override default */
Kurt A. O'Hearn
committed
spmd_handle->output_enabled = FALSE;
Kurt A. O'Hearn
committed
Read_Input_Files( NULL, ffield_file, control_file,
spmd_handle->system, spmd_handle->control,
spmd_handle->data, spmd_handle->workspace,
spmd_handle->out_control, FALSE );
Kurt A. O'Hearn
committed
spmd_handle->system->N_qm = *qm_num_atoms;
spmd_handle->system->N_mm = *mm_num_atoms;
spmd_handle->system->N = spmd_handle->system->N_qm + spmd_handle->system->N_mm;
Kurt A. O'Hearn
committed
/* note: assign here to avoid compiler warning
* of uninitialized usage in PreAllocate_Space */
spmd_handle->system->N_max = 0;
Kurt A. O'Hearn
committed
PreAllocate_Space( spmd_handle->system, spmd_handle->control,
Kurt A. O'Hearn
committed
spmd_handle->workspace, (int) CEIL( SAFE_ZONE * spmd_handle->system->N ) );
Kurt A. O'Hearn
committed
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
Setup_Box( sim_box_info[0], sim_box_info[1], sim_box_info[2],
sim_box_info[3], sim_box_info[4], sim_box_info[5],
&spmd_handle->system->box );
for ( i = 0; i < spmd_handle->system->N_qm; ++i )
{
x[0] = qm_pos[3 * i];
x[1] = qm_pos[3 * i + 1];
x[2] = qm_pos[3 * i + 2];
Fit_to_Periodic_Box( &spmd_handle->system->box, x );
spmd_handle->workspace->orig_id[i] = i + 1;
// spmd_handle->system->atoms[i].type = Get_Atom_Type( &system->reax_param,
// element, sizeof(element) );
spmd_handle->system->atoms[i].type = qm_types[i];
// strncpy( spmd_handle->system->atoms[i].name, atom_name,
// sizeof(spmd_handle->system->atoms[i].name) - 1 );
// spmd_handle->system->atoms[i].name[sizeof(spmd_handle->system->atoms[i].name) - 1] = '\0';
rvec_Copy( spmd_handle->system->atoms[i].x, x );
rvec_MakeZero( spmd_handle->system->atoms[i].v );
rvec_MakeZero( spmd_handle->system->atoms[i].f );
spmd_handle->system->atoms[i].q = 0.0;
spmd_handle->system->atoms[i].q_init = 0.0;
spmd_handle->system->atoms[i].qmmm_mask = TRUE;
}
for ( i = spmd_handle->system->N_qm; i < spmd_handle->system->N; ++i )
{
x[0] = mm_pos_q[4 * (i - spmd_handle->system->N_qm)];
x[1] = mm_pos_q[4 * (i - spmd_handle->system->N_qm) + 1];
x[2] = mm_pos_q[4 * (i - spmd_handle->system->N_qm) + 2];
Fit_to_Periodic_Box( &spmd_handle->system->box, x );
spmd_handle->workspace->orig_id[i] = i + 1;
// spmd_handle->system->atoms[i].type = Get_Atom_Type( &system->reax_param,
// element, sizeof(element) );
spmd_handle->system->atoms[i].type = mm_types[i - spmd_handle->system->N_qm];
// strncpy( spmd_handle->system->atoms[i].name, atom_name,
// sizeof(spmd_handle->system->atoms[i].name) - 1 );
// spmd_handle->system->atoms[i].name[sizeof(spmd_handle->system->atoms[i].name) - 1] = '\0';
rvec_Copy( spmd_handle->system->atoms[i].x, x );
rvec_MakeZero( spmd_handle->system->atoms[i].v );
rvec_MakeZero( spmd_handle->system->atoms[i].f );
spmd_handle->system->atoms[i].q = mm_pos_q[4 * (i - spmd_handle->system->N_qm) + 3];
spmd_handle->system->atoms[i].q_init = mm_pos_q[4 * (i - spmd_handle->system->N_qm) + 3];
spmd_handle->system->atoms[i].qmmm_mask = FALSE;
}
spmd_handle->system->N_max = (int) CEIL( SAFE_ZONE * spmd_handle->system->N );
*handle = (void *) spmd_handle;
Kurt A. O'Hearn
committed
}
/* Reset for the next simulation by parsing input files and triggering
* reallocation if more space is needed
*
* handle: pointer to wrapper struct with top-level data structures
* qm_num_atoms: num. atoms in the QM region
* qm_types: element types for QM atoms
Kurt A. O'Hearn
committed
* qm_pos: coordinates of QM atom positions (consecutively arranged), in Angstroms
Kurt A. O'Hearn
committed
* mm_num_atoms: num. atoms in the MM region
* mm_types: element types for MM atoms
Kurt A. O'Hearn
committed
* mm_pos_q: coordinates and charges of MM atom positions (consecutively arranged), in Angstroms / Coulombs
Kurt A. O'Hearn
committed
* sim_box_info: simulation box information, where the entries are
* - box length per dimension (3 entries)
* - angles per dimension (3 entries)
* ffield_file: file containing force field parameters
* control_file: file containing simulation parameters
*/
void reset_qmmm_( const void * const handle,
const int * const qm_num_atoms, const int * const qm_types,
Kurt A. O'Hearn
committed
const double * const qm_pos, const int * const mm_num_atoms,
const int * const mm_types, const double * const mm_pos_q,
const double * const sim_box_info, const char * const ffield_file,
const char * const control_file )
Kurt A. O'Hearn
committed
{
Kurt A. O'Hearn
committed
int i, ret;
rvec x;
spuremd_handle *spmd_handle;
ret = SPUREMD_FAILURE;
if ( handle != NULL )
{
spmd_handle = (spuremd_handle*) handle;
/* close files used in previous simulation */
if ( spmd_handle->output_enabled == TRUE )
{
Finalize_Out_Controls( spmd_handle->system, spmd_handle->control,
spmd_handle->workspace, spmd_handle->out_control );
}
spmd_handle->realloc = FALSE;
spmd_handle->data->sim_id++;
Kurt A. O'Hearn
committed
Read_Input_Files( NULL, ffield_file, control_file,
spmd_handle->system, spmd_handle->control,
spmd_handle->data, spmd_handle->workspace,
spmd_handle->out_control, TRUE );
Kurt A. O'Hearn
committed
spmd_handle->system->N_qm = *qm_num_atoms;
spmd_handle->system->N_mm = *mm_num_atoms;
spmd_handle->system->N = spmd_handle->system->N_qm + spmd_handle->system->N_mm;
Kurt A. O'Hearn
committed
Kurt A. O'Hearn
committed
if ( spmd_handle->system->prealloc_allocated == FALSE
|| spmd_handle->system->N > spmd_handle->system->N_max )
{
PreAllocate_Space( spmd_handle->system, spmd_handle->control,
spmd_handle->workspace, (int) CEIL( SAFE_ZONE * spmd_handle->system->N ) );
}
Kurt A. O'Hearn
committed
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
Setup_Box( sim_box_info[0], sim_box_info[1], sim_box_info[2],
sim_box_info[3], sim_box_info[4], sim_box_info[5],
&spmd_handle->system->box );
for ( i = 0; i < spmd_handle->system->N_qm; ++i )
{
x[0] = qm_pos[3 * i];
x[1] = qm_pos[3 * i + 1];
x[2] = qm_pos[3 * i + 2];
Fit_to_Periodic_Box( &spmd_handle->system->box, x );
spmd_handle->workspace->orig_id[i] = i + 1;
// spmd_handle->system->atoms[i].type = Get_Atom_Type( &system->reax_param,
// element, sizeof(element) );
spmd_handle->system->atoms[i].type = qm_types[i];
// strncpy( spmd_handle->system->atoms[i].name, atom_name,
// sizeof(spmd_handle->system->atoms[i].name) - 1 );
// spmd_handle->system->atoms[i].name[sizeof(spmd_handle->system->atoms[i].name) - 1] = '\0';
rvec_Copy( spmd_handle->system->atoms[i].x, x );
rvec_MakeZero( spmd_handle->system->atoms[i].v );
rvec_MakeZero( spmd_handle->system->atoms[i].f );
spmd_handle->system->atoms[i].q = 0.0;
spmd_handle->system->atoms[i].qmmm_mask = TRUE;
}
for ( i = spmd_handle->system->N_qm; i < spmd_handle->system->N; ++i )
{
x[0] = mm_pos_q[4 * (i - spmd_handle->system->N_qm)];
x[1] = mm_pos_q[4 * (i - spmd_handle->system->N_qm) + 1];
x[2] = mm_pos_q[4 * (i - spmd_handle->system->N_qm) + 2];
Fit_to_Periodic_Box( &spmd_handle->system->box, x );
spmd_handle->workspace->orig_id[i] = i + 1;
// spmd_handle->system->atoms[i].type = Get_Atom_Type( &system->reax_param,
// element, sizeof(element) );
spmd_handle->system->atoms[i].type = mm_types[i - spmd_handle->system->N_qm];
// strncpy( spmd_handle->system->atoms[i].name, atom_name,
// sizeof(spmd_handle->system->atoms[i].name) - 1 );
// spmd_handle->system->atoms[i].name[sizeof(spmd_handle->system->atoms[i].name) - 1] = '\0';
rvec_Copy( spmd_handle->system->atoms[i].x, x );
rvec_MakeZero( spmd_handle->system->atoms[i].v );
rvec_MakeZero( spmd_handle->system->atoms[i].f );
spmd_handle->system->atoms[i].q = mm_pos_q[4 * (i - spmd_handle->system->N_qm) + 3];
spmd_handle->system->atoms[i].qmmm_mask = FALSE;
}
if ( spmd_handle->system->N > spmd_handle->system->N_max )
{
/* deallocate everything which needs more space
* (i.e., structures whose space is a function of the number of atoms),
* except for data structures allocated while parsing input files */
Finalize( spmd_handle->system, spmd_handle->control, spmd_handle->data,
spmd_handle->workspace, spmd_handle->lists, spmd_handle->out_control,
spmd_handle->output_enabled, TRUE );
spmd_handle->system->N_max = (int) CEIL( SAFE_ZONE * spmd_handle->system->N );
spmd_handle->realloc = TRUE;
}
ret = SPUREMD_SUCCESS;
}
Kurt A. O'Hearn
committed
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
if ( ret != SPUREMD_SUCCESS )
{
/* TODO: pass errors via another mechanism */
;
}
}
/* Run the simulation according to the prescribed parameters
*
* handle: pointer to wrapper struct with top-level data structures
*/
void simulate_( const void * const handle )
{
int ret;
ret = simulate( handle );
if ( ret != SPUREMD_SUCCESS )
{
/* TODO: pass errors via another mechanism */
;
}
}
/* Deallocate all data structures post-simulation
*
* handle: pointer to wrapper struct with top-level data structures
*/
void cleanup_( const void * const handle )
{
int ret;
ret = cleanup( handle );
if ( ret != SPUREMD_SUCCESS )
{
/* TODO: pass errors via another mechanism */
;
}
}
/* Setter for writing output to files
*
* handle: pointer to wrapper struct with top-level data structures
* enabled: TRUE enables writing output to files, FALSE otherwise
*/
void set_output_enabled_( const void * const handle, const int enabled )
{
int ret;
ret = set_output_enabled( handle, enabled );
if ( ret != SPUREMD_SUCCESS )
{
/* TODO: pass errors via another mechanism */
;
}
}
/* Setter for simulation parameter values as defined in the input control file
*
* handle: pointer to wrapper struct with top-level data structures
* control_keyword: keyword from the control file to set the value for
* control_value: value to set
*/
void set_control_parameter_( const void * const handle, const char * const keyword,
const char ** const values )
{
int ret;
ret = set_control_parameter( handle, keyword, values );
if ( ret != SPUREMD_SUCCESS )
{
/* TODO: pass errors via another mechanism */
;
}
}
/* Getter for atom forces in QMMM mode
*
* handle: pointer to wrapper struct with top-level data structures
Kurt A. O'Hearn
committed
* qm_f: coordinates of QM atom forces (consecutively arranged), in Angstroms * Daltons / ps^2 (allocated by caller)
* mm_f: coordinates of MM atom forces (consecutively arranged), in Angstroms * Daltons / ps^2 (allocated by caller)
Kurt A. O'Hearn
committed
*/
Kurt A. O'Hearn
committed
void get_atom_forces_qmmm_( const void * const handle, double * const qm_f,
double * const mm_f )
Kurt A. O'Hearn
committed
{
int ret;
Kurt A. O'Hearn
committed
ret = get_atom_forces_qmmm( handle, qm_f, mm_f );
Kurt A. O'Hearn
committed
if ( ret != SPUREMD_SUCCESS )
{
/* TODO: pass errors via another mechanism */
;
}
}
/* Getter for atom charges in QMMM mode
*
* handle: pointer to wrapper struct with top-level data structures
* qm_q: QM atom charges, in Coulombs (allocated by caller)
*
* returns: SPUREMD_SUCCESS upon success, SPUREMD_FAILURE otherwise
*/
Kurt A. O'Hearn
committed
void get_atom_charges_qmmm_( const void * const handle, double * const qm_q )
Kurt A. O'Hearn
committed
{
int ret;
Kurt A. O'Hearn
committed
ret = get_atom_charges_qmmm( handle, qm_q, NULL );
Kurt A. O'Hearn
committed
if ( ret != SPUREMD_SUCCESS )
{
/* TODO: pass errors via another mechanism */
;
}
}
/* Getter for system energies
*
* handle: pointer to wrapper struct with top-level data structures
* e_tot: system total energy, in kcal / mol (reference from caller)
*/
Kurt A. O'Hearn
committed
void get_system_info_( const void * const handle, double * const e_tot )
Kurt A. O'Hearn
committed
{
int ret;
Kurt A. O'Hearn
committed
ret = get_system_info( handle, NULL, NULL, e_tot, NULL, NULL, NULL );
Kurt A. O'Hearn
committed
if ( ret != SPUREMD_SUCCESS )
{
/* TODO: pass errors via another mechanism */
;
}
}
#endif