Gromacs
5.1.4
|
#include "gmxpre.h"
#include "swapcoords.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include "gromacs/fileio/confio.h"
#include "gromacs/fileio/xvgr.h"
#include "gromacs/legacyheaders/copyrite.h"
#include "gromacs/legacyheaders/macros.h"
#include "gromacs/legacyheaders/mdrun.h"
#include "gromacs/legacyheaders/names.h"
#include "gromacs/legacyheaders/network.h"
#include "gromacs/legacyheaders/typedefs.h"
#include "gromacs/math/vec.h"
#include "gromacs/mdlib/groupcoord.h"
#include "gromacs/pbcutil/pbc.h"
#include "gromacs/timing/wallcycle.h"
#include "gromacs/topology/mtop_util.h"
#include "gromacs/utility/cstringutil.h"
#include "gromacs/utility/smalloc.h"
Implements functions in swapcoords.h.
Classes | |
struct | swap_compartment |
Structure containing compartment-specific data. More... | |
struct | swap_group |
This structure contains data needed for each of the groups involved in swapping: ions, water, and channels. More... | |
struct | t_swap |
Main (private) data structure for the position swapping protocol. More... | |
Typedefs | |
typedef struct swap_compartment | t_compartment |
Structure containing compartment-specific data. More... | |
typedef struct swap_group | t_group |
This structure contains data needed for each of the groups involved in swapping: ions, water, and channels. More... | |
typedef struct t_swap | t_swap |
Main (private) data structure for the position swapping protocol. More... | |
Enumerations | |
enum | { eGrpIons, eGrpSplit0, eGrpSplit1, eGrpSolvent, eGrpNr } |
enum | eChannelHistory { eChHistPassedNone, eChHistPassedCh0, eChHistPassedCh1, eChHistNr } |
Keep track of through which channel the ions have passed. | |
enum | eDomain { eDomainNotset, eDomainA, eDomainB, eDomainNr } |
Domain identifier. More... | |
Functions | |
static gmx_bool | is_in_channel (rvec point, rvec center, real d_up, real d_down, real r_cyl2, t_pbc *pbc, int normal) |
Check whether point is in channel. More... | |
static void | print_ionlist (t_swap *s, double time, const char comment[]) |
Prints to swap output file which ions are in which compartment. | |
static void | get_molecule_center (rvec x[], int nat, real *weights, rvec center, t_pbc *pbc) |
Get the center of a group of nat atoms. More... | |
static gmx_bool | compartment_contains_atom (real w1, real w2, real gap, real x, real l, real *distance_from_center) |
Return TRUE if ion is found in the compartment. More... | |
static void | update_time_window (t_compartment *comp, int values, int replace) |
Updates the time-averaged number of ions in a compartment. | |
static void | add_to_list (int ci, t_compartment *comp, real distance) |
Add atom with collective index ci to the list 'comp'. | |
static void | get_compartment_boundaries (int c, t_swap *s, matrix box, real *left, real *right) |
Determine the compartment boundaries from the channel centers. | |
static void | detect_flux_per_channel (int iion, int comp, int iontype, rvec ion_pos, unsigned char *comp_now, unsigned char *comp_from, unsigned char *channel_label, t_swapcoords *sc, real cyl0_r2, real cyl1_r2, gmx_int64_t step, gmx_bool bRerun, FILE *fpout) |
Determine the per-channel ion flux. More... | |
static void | compartmentalize_ions (t_commrec *cr, t_swapcoords *sc, matrix box, gmx_int64_t step, FILE *fpout, gmx_bool bRerun) |
Get the lists of ions for the two compartments. | |
static void | compartmentalize_solvent (t_commrec *cr, t_swapcoords *sc, matrix box, FILE *fpout) |
Set up the compartments and get lists of solvent atoms in each compartment. | |
static void | get_initial_ioncounts (t_inputrec *ir, rvec x[], matrix box, t_commrec *cr, gmx_bool bRerun) |
Find out how many group atoms are in the compartments initially. | |
static void | get_initial_ioncounts_from_cpt (t_inputrec *ir, swapstate_t *swapstate, t_commrec *cr, gmx_bool bVerbose) |
Copy history of ion counts from checkpoint file. More... | |
static void | bc_initial_concentrations (t_commrec *cr, t_swapcoords *swap) |
The master lets all others know about the initial ion counts. | |
static void | check_swap_groups (t_swap *s, int nat, gmx_bool bVerbose) |
Ensure that each atom belongs to at most one of the swap groups. | |
static int | get_group_apm_check (int group, t_swap *s, gmx_bool bVerbose, const gmx_mtop_atomlookup_t alook, gmx_mtop_t *mtop) |
Get the number of atoms per molecule for this group. More... | |
static void | print_ionlist_legend (t_inputrec *ir, const output_env_t oenv) |
Print the legend to the swap output file. More... | |
static void | detect_flux_per_channel_init (t_commrec *cr, t_swap *s, swapstate_t *swapstate, gmx_bool bStartFromCpt) |
Initialize channel ion flux detection routine. More... | |
static void | outputStartStructureIfWanted (gmx_mtop_t *mtop, rvec *x, int ePBC, matrix box) |
Outputs the initial structure to PDB file for debugging reasons. More... | |
static void | init_swapstate (swapstate_t *swapstate, t_swapcoords *sc, gmx_mtop_t *mtop, rvec x[], matrix box, int ePBC) |
Initialize the swapstate structure, used for checkpoint writing. More... | |
void | init_swapcoords (FILE *fplog, gmx_bool bVerbose, t_inputrec *ir, const char *fn, gmx_mtop_t *mtop, rvec x[], matrix box, swapstate_t *swapstate, t_commrec *cr, const output_env_t oenv, unsigned long Flags) |
Initialize ion / water position swapping ("Computational Electrophysiology"). More... | |
void | dd_make_local_swap_groups (gmx_domdec_t *dd, t_swapcoords *sc) |
Make a selection of the home atoms for the swap groups. These are the ions, the water, and the channels. This routine should be called at every domain decomposition. More... | |
static gmx_bool | need_swap (t_swapcoords *sc) |
Do we need to swap ions with water molecules at this step? More... | |
static int | get_index_of_distant_atom (t_compartment *comp, int apm) |
Return index of atom that we can use for swapping. More... | |
static void | translate_positions (rvec *x, int apm, rvec old_com, rvec new_com, t_pbc *pbc) |
Swaps centers of mass and makes molecule whole if broken. | |
static void | apply_modified_positions (t_group *g, rvec x[]) |
Write back the the modified local positions from the collective array to the official positions. | |
gmx_bool | do_swapcoords (t_commrec *cr, gmx_int64_t step, double t, t_inputrec *ir, gmx_wallcycle_t wcycle, rvec x[], matrix box, gmx_mtop_t *mtop, gmx_bool bVerbose, gmx_bool bRerun) |
"Computational Electrophysiology" main routine within MD loop. More... | |
Variables | |
static const char * | SwS = {"SWAP:"} |
For output that comes from the swap module. | |
static const char * | SwSEmpty = {" "} |
Placeholder for multi-line output. | |
static const char * | IonString [eIonNR] = {"anion", "cation" } |
Type of ion, used for verbose output. | |
static const char * | IonStr [eIonNR] = {"-", "+" } |
Type of ion, used for short output. | |
static const char * | CompStr [eCompNR] = {"A", "B" } |
Compartment name. | |
static const char * | SwapStr [eSwapTypesNR+1] = { "", "X-", "Y-", "Z-", NULL} |
Name for the swap types. More... | |
static const char * | DimStr [3+1] = { "X", "Y", "Z", NULL} |
Name for the swap dimension. More... | |
static const char * | GrpString [eGrpNr] = { "ion", "split0", "split1", "solvent" } |
Group name. | |
static const char * | ChannelString [eChHistNr] = { "none", "channel0", "channel1" } |
Name for the channels. | |
static const char * | DomainString [eDomainNr] = { "not_assigned", "Domain_A", "Domain_B" } |
Name for the domains. | |
typedef struct swap_compartment t_compartment |
Structure containing compartment-specific data.
typedef struct swap_group t_group |
This structure contains data needed for each of the groups involved in swapping: ions, water, and channels.
enum eDomain |
Domain identifier.
Keeps track of from which compartment the ions came before passing the channel.
|
static |
Return TRUE if ion is found in the compartment.
Returns TRUE if x is between (w1+gap) and (w2-gap)
void dd_make_local_swap_groups | ( | gmx_domdec_t * | dd, |
t_swapcoords * | si_pub | ||
) |
Make a selection of the home atoms for the swap groups. These are the ions, the water, and the channels. This routine should be called at every domain decomposition.
[in] | dd | Structure containing domain decomposition data. |
[in] | si_pub | Pointer to the swap data structure. |
|
static |
Determine the per-channel ion flux.
To determine the flux through the individual channels, we remember the compartment and channel history of each ion. An ion can be either in channel0 or channel1, or in the remaining volume of compartment A or B.
|
static |
Initialize channel ion flux detection routine.
Initialize arrays that keep track of where the ions come from and where they go.
gmx_bool do_swapcoords | ( | t_commrec * | cr, |
gmx_int64_t | step, | ||
double | t, | ||
t_inputrec * | ir, | ||
gmx_wallcycle_t | wcycle, | ||
rvec | x[], | ||
matrix | box, | ||
gmx_mtop_t * | mtop, | ||
gmx_bool | bVerbose, | ||
gmx_bool | bRerun | ||
) |
"Computational Electrophysiology" main routine within MD loop.
[in] | cr | Pointer to MPI communication data. |
[in] | step | The number of the MD time step. |
[in] | t | The time. |
[in] | ir | Structure containing MD input parameters, among those also the structure needed for position swapping. |
[in] | wcycle | Count wallcycles of swap routines for diagnostic output. |
[in] | x | Positions of home particles this node owns. |
[in] | box | The simulation box. |
[in] | mtop | Molecular topology. |
[in] | bVerbose | Should we be quiet or verbose? |
[in] | bRerun | Are we doing a rerun? |
|
static |
Get the number of atoms per molecule for this group.
Also ensure that all the molecules in this group have this number of atoms.
|
static |
Return index of atom that we can use for swapping.
Returns the index of an atom that is far off the compartment boundaries. Other atoms of the molecule (if any) will directly follow the returned index
|
static |
Copy history of ion counts from checkpoint file.
When called, the checkpoint file has already been read in. Here we copy over the values from .cpt file to the swap data structure.
|
static |
Get the center of a group of nat atoms.
Since with PBC an atom group might not be whole, use the first atom as the reference atom and determine the center with respect to this reference.
void init_swapcoords | ( | FILE * | fplog, |
gmx_bool | bVerbose, | ||
t_inputrec * | ir, | ||
const char * | fn, | ||
gmx_mtop_t * | mtop, | ||
rvec | x[], | ||
matrix | box, | ||
swapstate_t * | swapstate, | ||
t_commrec * | cr, | ||
const output_env_t | oenv, | ||
unsigned long | Flags | ||
) |
Initialize ion / water position swapping ("Computational Electrophysiology").
This routine does the memory allocation for various helper arrays, opens the output file, sets up swap data checkpoint writing, etc.
[in] | fplog | General output file, normally md.log. |
[in] | bVerbose | Should we be quiet or verbose? |
[in] | ir | Structure containing MD input parameters, among those also the structure needed for position swapping. |
[in] | fn | Output file name for swap data. |
[in] | mtop | Molecular topology. |
[in] | x | The initial positions of all particles. |
[in] | box | The simulation box. |
[in] | swapstate | Swap-related data that is read from or written to checkpoint. |
[in] | cr | Pointer to MPI communication data. |
[in] | oenv | Needed to open the swap output XVGR file. |
[in] | Flags | Flags passed over from main, used to determine whether we are doing a rerun, appending, etc. |
|
static |
Initialize the swapstate structure, used for checkpoint writing.
The swapstate struct stores the information we need to make the channels whole again after restarts from a checkpoint file. Here we do the following:
a) If we did not start from .cpt, we prepare the struct for proper .cpt writing,
b) if we did start from .cpt, we copy over the last whole structures from .cpt,
c) in any case, for subsequent checkpoint writing, we set the pointers in
swapstate to the x_old arrays, which contain the correct PBC representation of multimeric channels at the last time step.
|
static |
Check whether point is in channel.
A channel is a cylinder defined by a disc with radius r around its center c. The thickness of the cylinder is d_up - d_down.
|
static |
Do we need to swap ions with water molecules at this step?
From the requested and average ion counts we determine whether a swap is needed at this time step.
|
static |
Outputs the initial structure to PDB file for debugging reasons.
Output the starting structure so that in case of multimeric channels the user can check whether we have the correct PBC image for all atoms. If this is not correct, the ion counts per channel will be very likely wrong.
|
static |
Print the legend to the swap output file.
Also print the initial ion counts
|
static |
Name for the swap dimension.
|
static |
Name for the swap types.