Newer
Older
Kurt A. O'Hearn
committed
ret_ = Set_Control_Parameter( keyword, values, spmd_handle->control,
spmd_handle->out_control );
Kurt A. O'Hearn
committed
Kurt A. O'Hearn
committed
if ( ret_ == SUCCESS )
{
ret = SPUREMD_SUCCESS;
}
}
return ret;
}
Kurt A. O'Hearn
committed
#if defined(QMMM)
/* Allocate top-level data structures and parse input files
* for the first simulation
*
* qm_num_atoms: num. atoms in the QM region
Kurt A. O'Hearn
committed
* qm_symbols: 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
Kurt A. O'Hearn
committed
* mm_symbols: 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)
Kurt A. O'Hearn
committed
* num_charge_constraint_contig: num. of contiguous charge constraints for charge model
* charge_constraint_contig_start: starting atom num. (1-based) of atom group for a charge constraint
* charge_constraint_contig_end: ending atom num. (1-based) of atom group for a charge constraint
* charge_constraint_contig_value: charge constraint value for atom group
* num_charge_constraint_custom: num. of custom charge constraints for charge model
* charge_constraint_custom_count: counts for each custom charge constraint
* charge_constraint_custom_atom_index: atom indices (1-based) for custom charge constraints
* charge_constraint_custom_coeff: coefficients for custom charge constraints
* charge_constraint_custom_rhs: right-hand side (RHS) constants for custom charge constraints
Kurt A. O'Hearn
committed
* ffield_file: file containing force field parameters
* control_file: file containing simulation parameters
*/
Kurt A. O'Hearn
committed
void * setup_qmmm( int qm_num_atoms, const char * const qm_symbols,
const double * const qm_pos, int mm_num_atoms, const char * const mm_symbols,
Kurt A. O'Hearn
committed
const double * const mm_pos_q, const double * const sim_box_info,
Kurt A. O'Hearn
committed
int num_charge_constraint_contig, const int * const charge_constraint_contig_start,
const int * const charge_constraint_contig_end, const double * const charge_constraint_contig_value,
int num_charge_constraint_custom, const int * const charge_constraint_custom_count,
const int * const charge_constraint_custom_atom_index,
const double * const charge_constraint_custom_coeff,
const double * const charge_constraint_custom_rhs,
Kurt A. O'Hearn
committed
const char * const ffield_file, const char * const control_file )
Kurt A. O'Hearn
committed
{
int i;
Kurt A. O'Hearn
committed
char element[3];
Kurt A. O'Hearn
committed
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
Kurt A. O'Hearn
committed
spmd_handle->system->max_num_molec_charge_constraints = num_charge_constraint_contig;
spmd_handle->system->num_molec_charge_constraints = num_charge_constraint_contig;
Kurt A. O'Hearn
committed
if ( spmd_handle->system->num_molec_charge_constraints > 0 )
{
spmd_handle->system->molec_charge_constraints = smalloc(
sizeof(real) * spmd_handle->system->num_molec_charge_constraints,
Kurt A. O'Hearn
committed
__FILE__, __LINE__ );
Kurt A. O'Hearn
committed
spmd_handle->system->molec_charge_constraint_ranges = smalloc(
sizeof(int) * 2 * spmd_handle->system->num_molec_charge_constraints,
Kurt A. O'Hearn
committed
__FILE__, __LINE__ );
Kurt A. O'Hearn
committed
for ( i = 0; i < spmd_handle->system->num_molec_charge_constraints; ++i )
{
Kurt A. O'Hearn
committed
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
spmd_handle->system->molec_charge_constraint_ranges[2 * i] = charge_constraint_contig_start[i];
spmd_handle->system->molec_charge_constraint_ranges[2 * i + 1] = charge_constraint_contig_end[i];
spmd_handle->system->molec_charge_constraints[i] = charge_constraint_contig_value[i];
}
}
spmd_handle->system->max_num_custom_charge_constraints = num_charge_constraint_custom;
spmd_handle->system->num_custom_charge_constraints = num_charge_constraint_custom;
spmd_handle->system->num_custom_charge_constraint_entries = 0;
if ( spmd_handle->system->num_custom_charge_constraints > 0 )
{
spmd_handle->system->custom_charge_constraint_count = smalloc(
sizeof(int) * spmd_handle->system->num_custom_charge_constraints,
__FILE__, __LINE__ );
spmd_handle->system->custom_charge_constraint_start = smalloc(
sizeof(int) * (spmd_handle->system->num_custom_charge_constraints + 1),
__FILE__, __LINE__ );
spmd_handle->system->custom_charge_constraint_rhs = smalloc(
sizeof(real) * spmd_handle->system->num_custom_charge_constraints,
__FILE__, __LINE__ );
for ( i = 0; i < spmd_handle->system->num_custom_charge_constraints; ++i )
{
spmd_handle->system->custom_charge_constraint_count[i] = charge_constraint_custom_count[i];
spmd_handle->system->custom_charge_constraint_start[i] = (i == 0 ? 0 :
charge_constraint_custom_count[i - 1] + charge_constraint_custom_count[i - 1]);
spmd_handle->system->num_custom_charge_constraint_entries += charge_constraint_custom_count[i];
spmd_handle->system->custom_charge_constraint_rhs[i] = charge_constraint_custom_rhs[i];
}
}
spmd_handle->system->max_num_custom_charge_constraint_entries
= spmd_handle->system->num_custom_charge_constraint_entries;
if ( spmd_handle->system->num_custom_charge_constraint_entries > 0 )
{
spmd_handle->system->custom_charge_constraint_atom_index = smalloc(
sizeof(int) * spmd_handle->system->num_custom_charge_constraint_entries,
__FILE__, __LINE__ );
spmd_handle->system->custom_charge_constraint_coeff = smalloc(
sizeof(real) * spmd_handle->system->num_custom_charge_constraint_entries,
__FILE__, __LINE__ );
for ( i = 0; i < spmd_handle->system->num_custom_charge_constraint_entries; ++i )
{
spmd_handle->system->custom_charge_constraint_atom_index[i] = charge_constraint_custom_atom_index[i];
spmd_handle->system->custom_charge_constraint_coeff[i] = charge_constraint_custom_coeff[i];
Kurt A. O'Hearn
committed
}
}
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
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 );
Kurt A. O'Hearn
committed
element[2] = '\0';
Kurt A. O'Hearn
committed
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;
Kurt A. O'Hearn
committed
element[0] = toupper( qm_symbols[2 * i] );
element[1] = toupper( qm_symbols[2 * i + 1] );
Trim_Spaces( element, sizeof(element) );
spmd_handle->system->atoms[i].type = Get_Atom_Type( &spmd_handle->system->reax_param,
element, sizeof(element) );
strncpy( spmd_handle->system->atoms[i].name, element,
sizeof(spmd_handle->system->atoms[i].name) - 1 );
spmd_handle->system->atoms[i].name[sizeof(spmd_handle->system->atoms[i].name) - 1] = '\0';
Kurt A. O'Hearn
committed
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;
/* check for dummy atom */
if ( strncmp( element, "X\0", 2 ) == 0 )
{
spmd_handle->system->atoms[i].is_dummy = TRUE;
}
else
{
spmd_handle->system->atoms[i].is_dummy = FALSE;
}
Kurt A. O'Hearn
committed
}
for ( i = spmd_handle->system->N_qm; i < spmd_handle->system->N; ++i )
{
Kurt A. O'Hearn
committed
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];
Kurt A. O'Hearn
committed
Fit_to_Periodic_Box( &spmd_handle->system->box, x );
spmd_handle->workspace->orig_id[i] = i + 1;
Kurt A. O'Hearn
committed
element[0] = toupper( mm_symbols[2 * (i - spmd_handle->system->N_qm)] );
element[1] = toupper( mm_symbols[2 * (i - spmd_handle->system->N_qm) + 1] );
Trim_Spaces( element, sizeof(element) );
spmd_handle->system->atoms[i].type = Get_Atom_Type( &spmd_handle->system->reax_param,
element, sizeof(element) );
strncpy( spmd_handle->system->atoms[i].name, element,
sizeof(spmd_handle->system->atoms[i].name) - 1 );
spmd_handle->system->atoms[i].name[sizeof(spmd_handle->system->atoms[i].name) - 1] = '\0';
Kurt A. O'Hearn
committed
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 );
Kurt A. O'Hearn
committed
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];
Kurt A. O'Hearn
committed
spmd_handle->system->atoms[i].qmmm_mask = FALSE;
/* check for dummy atom */
if ( strncmp( element, "X\0", 2 ) == 0 )
{
spmd_handle->system->atoms[i].is_dummy = TRUE;
}
else
{
spmd_handle->system->atoms[i].is_dummy = FALSE;
}
Kurt A. O'Hearn
committed
}
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
Kurt A. O'Hearn
committed
* qm_symbols: 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
Kurt A. O'Hearn
committed
* mm_symbols: 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)
Kurt A. O'Hearn
committed
* num_charge_constraint_contig: num. of contiguous charge constraints for charge model
* charge_constraint_contig_start: starting atom num. (1-based) of atom group for a charge constraint
* charge_constraint_contig_end: ending atom num. (1-based) of atom group for a charge constraint
* charge_constraint_contig_value: charge constraint value for atom group
* num_charge_constraint_custom: num. of custom charge constraints for charge model
* charge_constraint_custom_count: counts for each custom charge constraint
* charge_constraint_custom_atom_index: atom indices (1-based) for custom charge constraints
* charge_constraint_custom_coeff: coefficients for custom charge constraints
* charge_constraint_custom_rhs: right-hand side (RHS) constants for custom charge constraints
Kurt A. O'Hearn
committed
* ffield_file: file containing force field parameters
* control_file: file containing simulation parameters
*
* returns: SPUREMD_SUCCESS upon success, SPUREMD_FAILURE otherwise
*/
Kurt A. O'Hearn
committed
int reset_qmmm( const void * const handle, int qm_num_atoms,
Kurt A. O'Hearn
committed
const char * const qm_symbols, const double * const qm_pos,
int mm_num_atoms, const char * const mm_symbols,
Kurt A. O'Hearn
committed
const double * const mm_pos_q, const double * const sim_box_info,
Kurt A. O'Hearn
committed
int num_charge_constraint_contig, const int * const charge_constraint_contig_start,
const int * const charge_constraint_contig_end, const double * const charge_constraint_contig_value,
int num_charge_constraint_custom, const int * const charge_constraint_custom_count,
const int * const charge_constraint_custom_atom_index,
const double * const charge_constraint_custom_coeff,
const double * const charge_constraint_custom_rhs,
Kurt A. O'Hearn
committed
const char * const ffield_file, const char * const control_file )
{
int i, ret;
Kurt A. O'Hearn
committed
char element[3];
Kurt A. O'Hearn
committed
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->num_molec_charge_constraints = num_charge_constraint_contig;
Kurt A. O'Hearn
committed
if ( spmd_handle->system->num_molec_charge_constraints
> spmd_handle->system->max_num_molec_charge_constraints )
{
if ( spmd_handle->system->max_num_molec_charge_constraints > 0 )
{
sfree( spmd_handle->system->molec_charge_constraints,
Kurt A. O'Hearn
committed
__FILE__, __LINE__ );
Kurt A. O'Hearn
committed
sfree( spmd_handle->system->molec_charge_constraint_ranges,
Kurt A. O'Hearn
committed
__FILE__, __LINE__ );
Kurt A. O'Hearn
committed
}
spmd_handle->system->molec_charge_constraints = smalloc(
sizeof(real) * spmd_handle->system->num_molec_charge_constraints,
Kurt A. O'Hearn
committed
__FILE__, __LINE__ );
Kurt A. O'Hearn
committed
spmd_handle->system->molec_charge_constraint_ranges = smalloc(
sizeof(int) * 2 * spmd_handle->system->num_molec_charge_constraints,
Kurt A. O'Hearn
committed
__FILE__, __LINE__ );
Kurt A. O'Hearn
committed
spmd_handle->system->max_num_molec_charge_constraints
= spmd_handle->system->num_molec_charge_constraints;
}
if ( spmd_handle->system->num_molec_charge_constraints > 0 )
{
for ( i = 0; i < spmd_handle->system->num_molec_charge_constraints; ++i )
{
Kurt A. O'Hearn
committed
1316
1317
1318
1319
1320
1321
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
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
spmd_handle->system->molec_charge_constraint_ranges[2 * i] = charge_constraint_contig_start[i];
spmd_handle->system->molec_charge_constraint_ranges[2 * i + 1] = charge_constraint_contig_end[i];
spmd_handle->system->molec_charge_constraints[i] = charge_constraint_contig_value[i];
}
}
spmd_handle->system->num_custom_charge_constraints = num_charge_constraint_custom;
if ( spmd_handle->system->num_custom_charge_constraints
> spmd_handle->system->max_num_custom_charge_constraints )
{
if ( spmd_handle->system->max_num_custom_charge_constraints > 0 )
{
sfree( spmd_handle->system->custom_charge_constraint_count,
__FILE__, __LINE__ );
sfree( spmd_handle->system->custom_charge_constraint_start,
__FILE__, __LINE__ );
sfree( spmd_handle->system->custom_charge_constraint_rhs,
__FILE__, __LINE__ );
}
spmd_handle->system->custom_charge_constraint_count = smalloc(
sizeof(int) * spmd_handle->system->num_custom_charge_constraints,
__FILE__, __LINE__ );
spmd_handle->system->custom_charge_constraint_start = smalloc(
sizeof(int) * (spmd_handle->system->num_custom_charge_constraints + 1),
__FILE__, __LINE__ );
spmd_handle->system->custom_charge_constraint_rhs = smalloc(
sizeof(real) * spmd_handle->system->num_custom_charge_constraints,
__FILE__, __LINE__ );
spmd_handle->system->max_num_custom_charge_constraints
= spmd_handle->system->num_custom_charge_constraints;
}
spmd_handle->system->num_custom_charge_constraint_entries = 0;
if ( spmd_handle->system->num_custom_charge_constraints > 0 )
{
for ( i = 0; i < spmd_handle->system->num_custom_charge_constraints; ++i )
{
spmd_handle->system->custom_charge_constraint_count[i] = charge_constraint_custom_count[i];
spmd_handle->system->custom_charge_constraint_start[i] = (i == 0 ? 0 :
charge_constraint_custom_count[i - 1] + charge_constraint_custom_count[i - 1]);
spmd_handle->system->num_custom_charge_constraint_entries += charge_constraint_custom_count[i];
spmd_handle->system->custom_charge_constraint_rhs[i] = charge_constraint_custom_rhs[i];
}
}
if ( spmd_handle->system->num_custom_charge_constraint_entries
> spmd_handle->system->max_num_custom_charge_constraint_entries )
{
if ( spmd_handle->system->max_num_custom_charge_constraint_entries > 0 )
{
sfree( spmd_handle->system->custom_charge_constraint_atom_index,
__FILE__, __LINE__ );
sfree( spmd_handle->system->custom_charge_constraint_coeff,
__FILE__, __LINE__ );
}
spmd_handle->system->custom_charge_constraint_atom_index = smalloc(
sizeof(int) * spmd_handle->system->num_custom_charge_constraint_entries,
__FILE__, __LINE__ );
spmd_handle->system->custom_charge_constraint_coeff = smalloc(
sizeof(real) * spmd_handle->system->num_custom_charge_constraint_entries,
__FILE__, __LINE__ );
spmd_handle->system->max_num_custom_charge_constraint_entries
= spmd_handle->system->num_custom_charge_constraint_entries;
}
if ( spmd_handle->system->num_custom_charge_constraint_entries > 0 )
{
for ( i = 0; i < spmd_handle->system->num_custom_charge_constraint_entries; ++i )
{
spmd_handle->system->custom_charge_constraint_atom_index[i] = charge_constraint_custom_atom_index[i];
spmd_handle->system->custom_charge_constraint_coeff[i] = charge_constraint_custom_coeff[i];
Kurt A. O'Hearn
committed
}
}
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 );
element[2] = '\0';
Kurt A. O'Hearn
committed
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;
Kurt A. O'Hearn
committed
element[0] = toupper( qm_symbols[2 * i] );
element[1] = toupper( qm_symbols[2 * i + 1] );
Trim_Spaces( element, sizeof(element) );
spmd_handle->system->atoms[i].type = Get_Atom_Type( &spmd_handle->system->reax_param,
element, sizeof(element) );
strncpy( spmd_handle->system->atoms[i].name, element,
sizeof(spmd_handle->system->atoms[i].name) - 1 );
spmd_handle->system->atoms[i].name[sizeof(spmd_handle->system->atoms[i].name) - 1] = '\0';
Kurt A. O'Hearn
committed
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;
Kurt A. O'Hearn
committed
spmd_handle->system->atoms[i].qmmm_mask = TRUE;
/* check for dummy atom */
if ( strncmp( element, "X\0", 2 ) == 0 )
{
spmd_handle->system->atoms[i].is_dummy = TRUE;
}
else
{
spmd_handle->system->atoms[i].is_dummy = FALSE;
}
Kurt A. O'Hearn
committed
}
for ( i = spmd_handle->system->N_qm; i < spmd_handle->system->N; ++i )
{
Kurt A. O'Hearn
committed
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];
Kurt A. O'Hearn
committed
Fit_to_Periodic_Box( &spmd_handle->system->box, x );
spmd_handle->workspace->orig_id[i] = i + 1;
Kurt A. O'Hearn
committed
element[0] = toupper( mm_symbols[2 * (i - spmd_handle->system->N_qm)] );
element[1] = toupper( mm_symbols[2 * (i - spmd_handle->system->N_qm) + 1] );
Trim_Spaces( element, sizeof(element) );
spmd_handle->system->atoms[i].type = Get_Atom_Type( &spmd_handle->system->reax_param,
element, sizeof(element) );
strncpy( spmd_handle->system->atoms[i].name, element,
sizeof(spmd_handle->system->atoms[i].name) - 1 );
spmd_handle->system->atoms[i].name[sizeof(spmd_handle->system->atoms[i].name) - 1] = '\0';
Kurt A. O'Hearn
committed
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 );
Kurt A. O'Hearn
committed
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];
Kurt A. O'Hearn
committed
spmd_handle->system->atoms[i].qmmm_mask = FALSE;
/* check for dummy atom */
if ( strncmp( element, "X\0", 2 ) == 0 )
{
spmd_handle->system->atoms[i].is_dummy = TRUE;
}
else
{
spmd_handle->system->atoms[i].is_dummy = FALSE;
}
Kurt A. O'Hearn
committed
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
}
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
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
}
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