ESPResSo 3.2.0-11-g9950804-git
Extensible Simulation Package for Soft Matter Research
Defines | Typedefs | Functions | Variables
maggs.c File Reference

Maxwell Equations Molecular Dynamics (MEMD) method for electrostatic interactions. More...

#include <mpi.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "ghosts.h"
#include "global.h"
#include "grid.h"
#include "integrate.h"
#include "initialize.h"
#include "interaction_data.h"
#include "particle_data.h"
#include "communication.h"
#include "maggs.h"
#include "thermostat.h"
#include "cells.h"
#include "domain_decomposition.h"
#include "errorhandling.h"
Include dependency graph for maggs.c:

Go to the source code of this file.

Defines

#define REQ_MAGGS_SPREAD   300
#define REQ_MAGGS_EQUIL   301
#define SELF_FACTOR_1   1.57364595
#define SELF_FACTOR_2   1.5078141
#define SPACE_DIM   3
#define NOWHERE   -1
#define NDIRS   6
#define XPLUS   0
#define YPLUS   1
#define ZPLUS   2
#define ZMINUS   3
#define YMINUS   4
#define XMINUS   5
#define OPP_DIR(dir)   (5-(dir))
#define FOR3D(dir)   for(dir=0; dir<SPACE_DIM; dir++)
#define FORALL_INNER_SITES(i, j, k)
#define FORALL_SITES(i, j, k)

Typedefs

typedef int t_ivector [SPACE_DIM]
typedef double t_dvector [SPACE_DIM]
typedef int t_dirs [NDIRS]

Functions

int maggs_get_linear_index (int x, int y, int z, int latticedim[SPACE_DIM])
 Turns the 3D index into a linear index.
int maggs_count_charged_particles ()
 Counts the total number of charged particles on all processors.
int maggs_get_offset (int index_shift, int index_base, int axes, int adim[3])
 Index shift is calculated for moving in various directions with the linear index.
void maggs_calc_directions (int j, int *dir1, int *dir2)
 For any direction j, write the two other directions into the pointers in circular permutation.
double maggs_calc_curl (int mue, int nue, double *field, int *Neighbor, int index)
 Calculates the finite differences rotation in real space in mue-nue plane: $\frac{\partial}{\partial t}{D} = \nabla \times B$ (and prefactors plus current) The given "double* field" should be a B-Field!!
double maggs_calc_dual_curl (int mue, int nue, double *field, int *Neighbor, int index)
 Calculates the finite differences rotation in dual space in mue-nue plane: $\frac{\partial}{\partial t}{B} = - \nabla \times D / (\epsilon)$ The given "double* field" should be a D-Field!!
void maggs_update_plaquette (int mue, int nue, int *Neighbor, int index, double delta)
 updates all D-fields on links of the plaquette and the surroundings.
int maggs_sanity_checks ()
 Basic sanity checks to see if the code will run.
void maggs_compute_dipole_correction ()
int maggs_set_parameters (double bjerrum, double f_mass, int mesh, int finite_epsilon_flag, double epsilon_infty)
 called from: initialize.c
void maggs_setup_neighbors ()
 sets up nearest neighbors for each site in linear index
void maggs_setup_local_lattice ()
 Set up lattice, calculate dimensions and lattice parameters Allocate memory for lattice sites and fields.
void maggs_calc_surface_patches (t_surf_patch *surface_patch)
 sets up surface patches for all domains.
void maggs_prepare_surface_planes (int dim, MPI_Datatype *xy, MPI_Datatype *xz, MPI_Datatype *yz, t_surf_patch *surface_patch)
 sets up MPI communications for domain surfaces
void maggs_exchange_surface_patch (double *field, int dim, int e_equil)
 MPI communication of surface region.
double maggs_interpol1D (double x)
 Interpolation function in one dimension.
void maggs_interpolate_charge (int *first, double *rel, double q)
 Does the actual interpolating calculation.
void maggs_accumulate_charge_from_ghosts ()
 add charges from ghost cells to lattice sites.
void maggs_distribute_particle_charges ()
 finds current lattice site of each particle.
void maggs_calc_charge_gradients (double *rel, double q, double *grad)
 Does the actual calculation of the gradient.
void maggs_update_charge_gradients (double *grad)
 finds correct lattice cube for particles.
void calc_self_energy_coeffs ()
 Calculate the self energy coefficients for the system, if corrected with Lattice Green's function.
double maggs_check_curl_E ()
 For energy minimization:
void maggs_perform_rot_move_inplane (int i, int n)
 If curl(E) is not zero, update plaquette with corrections.
void maggs_minimize_transverse_field ()
 For energy minimization: Relax B-fields in all directions.
void maggs_calc_init_e_field ()
 calculates initial electric field configuration.
void maggs_calc_charge_fluxes_1D (double q, double *help, double *flux, int dir)
 calculate the charge flux in direction "dir".
int maggs_check_intersect_1D (double delta, double r_new, int dir, int first, double *t_step, int identity)
 Extend particle trajectories on the one time step and check if the trajectory intersects the cell boundary in direction dirx#.
void maggs_calc_e_field_on_link_1D (int index, double *flux, double v, int dir)
 updates field on link coupling it with current.
void maggs_add_current_on_segment (Particle *p, int ghost_cell)
 loop over all cells and call charge current functions
void maggs_couple_current_to_Dfield ()
 Calculate fluxes and couple them with fields symplectically.
void maggs_propagate_B_field (double dt)
 propagate the B-field via $\frac{\partial}{\partial t}{B} = \nabla\times D$ (and prefactor) CAREFUL: Usually this function is called twice, with dt/2 each time to ensure a time reversible integration scheme!
void maggs_add_transverse_field (double dt)
 calculate D-field from B-field according to $\frac{\partial}{\partial t}{D} = \nabla\times B$ (and prefactors)
void interpolate_part_charge_from_grad (double rel_x, double *grad, double *rho)
 interpolation function, solely for new self force correction.
void calc_part_self_force (Particle *p)
 new self force correction with lattice Green's function.
void maggs_calc_self_influence (Particle *P)
 For each particle P, calculates self energy influence with direct Greens function, assuming constant permittivity on each lattice site.
void maggs_calc_part_link_forces (Particle *p, int index, double *grad)
 Calculate the actual force from the E-Field.
void maggs_calc_forces ()
 Public function.
double maggs_electric_energy ()
 integrates 0.5*D*E over the whole system public function!
double maggs_magnetic_energy ()
 Public funxtion.
void maggs_init ()
 Initialization function.
void maggs_exit ()
 Frees the dynamically allocated memory Currently not called from anywhere.

Variables

MAGGS_struct maggs = { 1, 1.0, 0. , 0. , 0. , 0. , 0. , 0 , 0. , 0. , {{0.},{0.}}}
static lattice_parameters lparams
static t_site * lattice
static double * Dfield
static double * Bfield
static t_dirsneighbor

Detailed Description

Maxwell Equations Molecular Dynamics (MEMD) method for electrostatic interactions.

We use a local update scheme to propagate artificial B-fields on a lattice in the system. In principal, the algorithm simulates full electrodynamics, but with a tunable speed of light.

The method is very usable for large particle numbers or highly parallel architectures, since it is local and scales linearly. It is not suited for high-precision calculation of forces, since the simple interpolation scheme produces errors in the order of 10^-5 in the force.

The chosen mesh should roughly be of the size of the particles.

Further reading on the algorithm: I. Pasichnyk and B. Dunweg, Coulomb interaction via local dynamics: a molecular-dynamics algorithm. J. Phys: Condens. Matter, 16 ,p. 1399-4020, (2004).

We use a local update scheme to propagate artificial B-fields on a lattice in the system. In principal, the algorithm simulates full electrodynamics, but with a tunable speed of light.

The method is very usable for large particle numbers or highly parallel architectures, since it is local and scales linearly. It is not suited for high-precision calculation of forces, since the simple interpolation scheme produces errors in the order of 10^-5 in the force.

The chosen mesh should roughly be of the size of the particles.

Further reading on the algorithm:

Definition in file maggs.c.


Define Documentation

#define FOR3D (   dir)    for(dir=0; dir<SPACE_DIM; dir++)
#define FORALL_INNER_SITES (   i,
  j,
 
)
Value:
for(i=lparams.inner_left_down[0];i<lparams.inner_up_right[0];i++)       \
    for(j=lparams.inner_left_down[1];j<lparams.inner_up_right[1];j++)   \
      for(k=lparams.inner_left_down[2];k<lparams.inner_up_right[2];k++)

Definition at line 96 of file maggs.c.

Referenced by maggs_calc_init_e_field(), maggs_check_curl_E(), maggs_electric_energy(), and maggs_magnetic_energy().

#define FORALL_SITES (   i,
  j,
 
)
Value:
for(i=0;i<lparams.dim[0];i++)                   \
    for(j=0;j<lparams.dim[1];j++)               \
      for(k=0;k<lparams.dim[2];k++)

Definition at line 101 of file maggs.c.

Referenced by maggs_setup_local_lattice().

#define NDIRS   6

Definition at line 83 of file maggs.c.

#define NOWHERE   -1

Definition at line 82 of file maggs.c.

Referenced by maggs_calc_e_field_on_link_1D(), and maggs_interpolate_charge().

#define OPP_DIR (   dir)    (5-(dir))

Definition at line 90 of file maggs.c.

Referenced by maggs_calc_curl().

#define REQ_MAGGS_EQUIL   301

Definition at line 70 of file maggs.c.

Referenced by maggs_calc_init_e_field().

#define REQ_MAGGS_SPREAD   300

Definition at line 69 of file maggs.c.

Referenced by maggs_exchange_surface_patch().

#define SELF_FACTOR_1   1.57364595

Definition at line 74 of file maggs.c.

Referenced by maggs_calc_self_influence().

#define SELF_FACTOR_2   1.5078141

Definition at line 75 of file maggs.c.

Referenced by maggs_calc_self_influence().

#define SPACE_DIM   3
#define XMINUS   5

Definition at line 89 of file maggs.c.

Referenced by maggs_calc_init_e_field(), and maggs_setup_neighbors().

#define XPLUS   0

Definition at line 84 of file maggs.c.

Referenced by maggs_calc_init_e_field(), and maggs_setup_neighbors().

#define YMINUS   4

Definition at line 88 of file maggs.c.

Referenced by maggs_calc_init_e_field(), and maggs_setup_neighbors().

#define YPLUS   1

Definition at line 85 of file maggs.c.

Referenced by maggs_calc_init_e_field(), maggs_get_linear_index(), and maggs_setup_neighbors().

#define ZMINUS   3

Definition at line 87 of file maggs.c.

Referenced by maggs_calc_init_e_field(), and maggs_setup_neighbors().

#define ZPLUS   2

Definition at line 86 of file maggs.c.

Referenced by maggs_calc_init_e_field(), maggs_get_linear_index(), and maggs_setup_neighbors().


Typedef Documentation

typedef int t_dirs[NDIRS]

Definition at line 113 of file maggs.c.

typedef double t_dvector[SPACE_DIM]

Definition at line 112 of file maggs.c.

typedef int t_ivector[SPACE_DIM]

Definition at line 111 of file maggs.c.


Function Documentation

void calc_part_self_force ( Particle p)

new self force correction with lattice Green's function.

Parameters:
pParticle pointer

Definition at line 2017 of file maggs.c.

References MAGGS_struct::alpha, ParticleForce::f, Particle::f, FOR3D, i, interpolate_part_charge_from_grad(), maggs_calc_charge_gradients(), maggs_calc_directions(), Particle::p, ParticleProperties::q, and SPACE_DIM.

void calc_self_energy_coeffs ( )

Calculate the self energy coefficients for the system, if corrected with Lattice Green's function.

Definition at line 1121 of file maggs.c.

References MAGGS_struct::alpha, i, MAGGS_struct::inva, M_PI, MAGGS_struct::mesh, MAGGS_struct::prefactor, SPACE_DIM, and SQR().

void interpolate_part_charge_from_grad ( double  rel_x,
double *  grad,
double *  rho 
)

interpolation function, solely for new self force correction.

Definition at line 1975 of file maggs.c.

References i.

Referenced by calc_part_self_force().

void maggs_accumulate_charge_from_ghosts ( )

add charges from ghost cells to lattice sites.

loop over ghost cells

Definition at line 969 of file maggs.c.

References CellPList::cell, FOR3D, ghost_cells, i, MAGGS_struct::inva, lparams, maggs_interpolate_charge(), CellPList::n, ParticleList::n, ParticlePosition::p, Particle::p, ParticleList::part, Particle::r, and SPACE_DIM.

Referenced by maggs_distribute_particle_charges().

void maggs_add_current_on_segment ( Particle p,
int  ghost_cell 
)
void maggs_add_transverse_field ( double  dt)

calculate D-field from B-field according to $\frac{\partial}{\partial t}{D} = \nabla\times B$ (and prefactors)

Parameters:
dtMD time step

Definition at line 1939 of file maggs.c.

References Bfield, Dfield, i, MAGGS_struct::inva, MAGGS_struct::invsqrt_f_mass, lparams, maggs_calc_curl(), maggs_exchange_surface_patch(), maggs_get_linear_index(), neighbor, and SQR().

Referenced by maggs_calc_forces().

void maggs_calc_charge_fluxes_1D ( double  q,
double *  help,
double *  flux,
int  dir 
)

calculate the charge flux in direction "dir".

Parameters:
qcharge of the moving particle
helpthe relative position in the cube to the opposite of left down front lattice site.
fluxflux variable to write into
dirdirection in which to calculate the flux

Definition at line 1633 of file maggs.c.

References MAGGS_struct::inva, maggs_calc_directions(), and MAGGS_struct::prefactor.

Referenced by maggs_add_current_on_segment().

void maggs_calc_charge_gradients ( double *  rel,
double  q,
double *  grad 
)

Does the actual calculation of the gradient.

Parameters:

Parameters:
rel3dim-array of relative position in cube,
qcharge,
gradhuge gradient array to write into

Definition at line 1046 of file maggs.c.

References FOR3D, i, and maggs_calc_directions().

Referenced by calc_part_self_force(), and maggs_update_charge_gradients().

double maggs_calc_curl ( int  mue,
int  nue,
double *  field,
int *  Neighbor,
int  index 
)

Calculates the finite differences rotation in real space in mue-nue plane: $\frac{\partial}{\partial t}{D} = \nabla \times B$ (and prefactors plus current) The given "double* field" should be a B-Field!!

Returns:
rotation result
Parameters:
muedirection 1 of plane to rotate in
nuedirection 2 of plane to rotate in
fieldinput B-field
Neighborneighbor lattice site
indexindex of current lattice site

Definition at line 350 of file maggs.c.

References OPP_DIR.

Referenced by maggs_add_transverse_field().

void maggs_calc_directions ( int  j,
int *  dir1,
int *  dir2 
)

For any direction j, write the two other directions into the pointers in circular permutation.

Parameters:
jgiven first direction
dir1write second direction into
dir2write third direction into

Definition at line 321 of file maggs.c.

Referenced by calc_part_self_force(), maggs_calc_charge_fluxes_1D(), maggs_calc_charge_gradients(), maggs_calc_e_field_on_link_1D(), and maggs_calc_part_link_forces().

double maggs_calc_dual_curl ( int  mue,
int  nue,
double *  field,
int *  Neighbor,
int  index 
)

Calculates the finite differences rotation in dual space in mue-nue plane: $\frac{\partial}{\partial t}{B} = - \nabla \times D / (\epsilon)$ The given "double* field" should be a D-Field!!

Returns:
rotation result
Parameters:
muedirection 1 of plane to rotate in
nuedirection 2 of plane to rotate in
fieldinput D-field
Neighborneighbor lattice site
indexindex of current lattice site

Definition at line 370 of file maggs.c.

Referenced by maggs_propagate_B_field().

void maggs_calc_e_field_on_link_1D ( int  index,
double *  flux,
double  v,
int  dir 
)

updates field on link coupling it with current.

Force is multiplied by the time_step

Parameters:
indexindex of lattice site
fluxcharge flux in lattice site
vspeed of particle
dirfirst direction of flux calculation

Definition at line 1707 of file maggs.c.

References Dfield, lattice, lparams, maggs_calc_directions(), maggs_get_offset(), neighbor, and NOWHERE.

Referenced by maggs_add_current_on_segment().

void maggs_calc_forces ( )
void maggs_calc_init_e_field ( )
void maggs_calc_part_link_forces ( Particle p,
int  index,
double *  grad 
)

Calculate the actual force from the E-Field.

Parameters:
pParticle pointer
indexindex of the lattice site
gradcharge gradient

Definition at line 2144 of file maggs.c.

References Dfield, ParticleForce::f, Particle::f, FOR3D, lattice, lparams, maggs_calc_directions(), maggs_get_offset(), neighbor, MAGGS_struct::prefactor, and SPACE_DIM.

Referenced by maggs_calc_forces().

void maggs_calc_self_influence ( Particle P)

For each particle P, calculates self energy influence with direct Greens function, assuming constant permittivity on each lattice site.

Parameters:
PParticle pointer

Definition at line 2080 of file maggs.c.

References MAGGS_struct::bjerrum, ParticleForce::f, Particle::f, FOR3D, MAGGS_struct::inva, lparams, ParticlePosition::p, Particle::p, ParticleProperties::q, Particle::r, SELF_FACTOR_1, SELF_FACTOR_2, and SPACE_DIM.

Referenced by maggs_calc_forces().

void maggs_calc_surface_patches ( t_surf_patch *  surface_patch)

sets up surface patches for all domains.

Parameters:
surface_patchthe local surface patch

Definition at line 697 of file maggs.c.

References lparams.

Referenced by maggs_exchange_surface_patch().

double maggs_check_curl_E ( )

For energy minimization:

Returns:
maximum of curl(E) from all sites. May also be used to verify constraint surface condition.

Definition at line 1195 of file maggs.c.

References comm_cart, Dfield, FORALL_INNER_SITES, i, MAGGS_struct::inva, iy, lparams, maggs_get_linear_index(), MPI_Allreduce(), MPI_DOUBLE, MPI_MAX, and neighbor.

Referenced by maggs_calc_init_e_field().

int maggs_check_intersect_1D ( double  delta,
double  r_new,
int  dir,
int  first,
double *  t_step,
int  identity 
)

Extend particle trajectories on the one time step and check if the trajectory intersects the cell boundary in direction dirx#.

Returns:
zero if no particle crosses intersection
Parameters:
deltaamount by which the particle moves
r_newcurrent position of particle
dirdirection in which to check for intersection
firstposition of particle within lattice cube
t_steptime step
identityparticle ID

Definition at line 1667 of file maggs.c.

References MAGGS_struct::a, MAGGS_TRACE, and sim_time.

Referenced by maggs_add_current_on_segment().

void maggs_compute_dipole_correction ( )
int maggs_count_charged_particles ( )

Counts the total number of charged particles on all processors.

Count the number of charges in the whole system.

Returns:
total number of charged particles in the system

Definition at line 272 of file maggs.c.

References CellPList::cell, comm_cart, i, local_cells, MPI_DOUBLE, MPI_Reduce(), MPI_SUM, CellPList::n, ParticleList::n, part, and ParticleList::part.

Referenced by mpi_bcast_event_slave().

void maggs_couple_current_to_Dfield ( )

Calculate fluxes and couple them with fields symplectically.

It is assumed that the particle can not cross more than one cell boundary per direction

loop over real particles

loop over ghost particles

Definition at line 1843 of file maggs.c.

References CellPList::cell, FOR3D, ghost_cells, i, local_cells, lparams, Particle::m, maggs_add_current_on_segment(), CellPList::n, ParticleList::n, ParticlePosition::p, ParticleList::part, Particle::r, and ParticleMomentum::v.

Referenced by maggs_calc_forces().

void maggs_distribute_particle_charges ( )

finds current lattice site of each particle.

calculates charge interpolation on cube.

=== charge assignment ===

loop over inner cells

Definition at line 1010 of file maggs.c.

References CellPList::cell, FOR3D, i, MAGGS_struct::inva, lattice, local_cells, lparams, maggs_accumulate_charge_from_ghosts(), maggs_interpolate_charge(), CellPList::n, ParticleList::n, ParticlePosition::p, ParticleList::part, Particle::r, and SPACE_DIM.

Referenced by maggs_calc_init_e_field().

double maggs_electric_energy ( )

integrates 0.5*D*E over the whole system public function!

Get the electric energy of the system as return value.

Returns:
returns electric energy

Definition at line 2269 of file maggs.c.

References MAGGS_struct::a, comm_cart, Dfield, FOR3D, FORALL_INNER_SITES, i, lattice, lparams, maggs_get_linear_index(), MPI_Allreduce(), MPI_DOUBLE, MPI_SUM, and SQR().

Referenced by calc_long_range_energies().

void maggs_exchange_surface_patch ( double *  field,
int  dim,
int  e_equil 
)

MPI communication of surface region.

works for D- and B-fields.

Parameters:
fieldField to communicate. Can be B- or D-field.
dimDimension in which to communicate
e_equilFlag if field is already equilibated

surface_patch

direction loop

pack send halo-plane data

communication

copy locally

Definition at line 791 of file maggs.c.

References comm_cart, maggs_calc_surface_patches(), maggs_prepare_surface_planes(), MPI_BYTE, MPI_DOUBLE, MPI_Irecv(), MPI_Isend(), MPI_REQUEST_NULL, MPI_Type_commit(), MPI_Type_contiguous(), MPI_Type_hvector(), MPI_Type_vector(), MPI_Waitall(), node_neighbors, REQ_MAGGS_SPREAD, request, and this_node.

Referenced by maggs_add_transverse_field(), maggs_calc_init_e_field(), maggs_minimize_transverse_field(), and maggs_propagate_B_field().

void maggs_exit ( )

Frees the dynamically allocated memory Currently not called from anywhere.

Clean up, free memory.

Definition at line 2341 of file maggs.c.

References Bfield, Dfield, free, lattice, and neighbor.

int maggs_get_linear_index ( int  x,
int  y,
int  z,
int  latticedim[SPACE_DIM] 
)

Turns the 3D index into a linear index.

adim contains the dimensions of the lattice in the 3 directions: adim[0] = x_max, ..., adim[2] = z_max z is the first index!!!

Returns:
linear index
Parameters:
xindex in x direction
yindex in y direction
zindex in z direction
latticedimdimensions of the lattice

Definition at line 263 of file maggs.c.

References YPLUS, and ZPLUS.

Referenced by maggs_add_current_on_segment(), maggs_add_transverse_field(), maggs_calc_forces(), maggs_calc_init_e_field(), maggs_check_curl_E(), maggs_electric_energy(), maggs_interpolate_charge(), maggs_magnetic_energy(), maggs_minimize_transverse_field(), maggs_propagate_B_field(), maggs_setup_local_lattice(), and maggs_setup_neighbors().

int maggs_get_offset ( int  index_shift,
int  index_base,
int  axes,
int  adim[3] 
)

Index shift is calculated for moving in various directions with the linear index.

Returns:
Offset of current node from base
Parameters:
index_shiftamount to move in direction
index_baseindex of base on current processor
axesin which direction to move
adimdimensions of the local lattice

Definition at line 304 of file maggs.c.

Referenced by maggs_calc_e_field_on_link_1D(), maggs_calc_part_link_forces(), and maggs_interpolate_charge().

void maggs_init ( )

Initialization function.

initialization function, parse command and set parameters.

Sets maggs structure variables. Calls calculation of initial D-field.

Definition at line 2314 of file maggs.c.

References MAGGS_struct::a, MAGGS_struct::bjerrum, Coulomb_parameters::bjerrum, box_l, coulomb, MAGGS_struct::inva, M_PI, maggs_calc_init_e_field(), maggs_sanity_checks(), maggs_setup_local_lattice(), MAGGS_struct::mesh, MAGGS_struct::pref2, MAGGS_struct::prefactor, and temperature.

Referenced by on_boxl_change(), on_cell_structure_change(), on_coulomb_change(), and on_observable_calc().

double maggs_interpol1D ( double  x)

Interpolation function in one dimension.

Currently only linear interpolation conserves charge.

Returns:
interpolation value
Parameters:
xrelative position of particle

Definition at line 911 of file maggs.c.

Referenced by maggs_interpolate_charge().

void maggs_interpolate_charge ( int *  first,
double *  rel,
double  q 
)

Does the actual interpolating calculation.

Parameters:
first3dim-array lattice position,
rel3dim-array relative position in cube,
qcharge to interpolate

relative pos. w.r.t. first

calculate charges at each vertex

Definition at line 924 of file maggs.c.

References FOR3D, i, lattice, lparams, maggs_get_linear_index(), maggs_get_offset(), maggs_interpol1D(), neighbor, NOWHERE, and SPACE_DIM.

Referenced by maggs_accumulate_charge_from_ghosts(), and maggs_distribute_particle_charges().

double maggs_magnetic_energy ( )

Public funxtion.

Get the magnetic energy of the artificial transversal field component as return value.

Integrates the B-field over the whole system to get the energy of the magnetic field.

Returns:
returns magnetic energy

Definition at line 2292 of file maggs.c.

References MAGGS_struct::a, Bfield, FORALL_INNER_SITES, i, lparams, maggs_get_linear_index(), and SQR().

void maggs_minimize_transverse_field ( )

For energy minimization: Relax B-fields in all directions.

Definition at line 1265 of file maggs.c.

References Dfield, FOR3D, i, lparams, maggs_exchange_surface_patch(), maggs_get_linear_index(), and maggs_perform_rot_move_inplane().

Referenced by maggs_calc_init_e_field().

void maggs_perform_rot_move_inplane ( int  i,
int  n 
)

If curl(E) is not zero, update plaquette with corrections.

Parameters:
iindex of the current lattice site
ncoordinate, is the normal direction to the plaquette

Definition at line 1227 of file maggs.c.

References Dfield, i, maggs_update_plaquette(), neighbor, and ROUND_ERROR_PREC.

Referenced by maggs_minimize_transverse_field().

void maggs_prepare_surface_planes ( int  dim,
MPI_Datatype xy,
MPI_Datatype xz,
MPI_Datatype yz,
t_surf_patch *  surface_patch 
)

sets up MPI communications for domain surfaces

Definition at line 762 of file maggs.c.

References MPI_BYTE, MPI_DOUBLE, MPI_Type_commit(), MPI_Type_contiguous(), and MPI_Type_vector().

Referenced by maggs_exchange_surface_patch().

void maggs_propagate_B_field ( double  dt)

propagate the B-field via $\frac{\partial}{\partial t}{B} = \nabla\times D$ (and prefactor) CAREFUL: Usually this function is called twice, with dt/2 each time to ensure a time reversible integration scheme!

Propagate the B-field in the system.

Parameters:
dttime step for update. Should be half the MD time step

Definition at line 1906 of file maggs.c.

References Bfield, Dfield, i, MAGGS_struct::invsqrt_f_mass, lparams, maggs_calc_dual_curl(), maggs_exchange_surface_patch(), maggs_get_linear_index(), and neighbor.

Referenced by integrate_vv().

int maggs_sanity_checks ( )

Basic sanity checks to see if the code will run.

Returns:
zero if everything is fine. -1 otherwise.

check if speed of light parameter makes sense

check for fixed particles

Definition at line 403 of file maggs.c.

References MAGGS_struct::a, MAGGS_struct::bjerrum, box_l, CellPList::cell, cell_structure, CELL_STRUCTURE_DOMDEC, COORDS_FIX_MASK, dd, ERROR_SPRINTF, ParticleLocal::ext_flag, MAGGS_struct::f_mass, FOR3D, i, Particle::l, local_cells, MAGGS_struct::mesh, CellPList::n, ParticleList::n, node_grid, ParticleList::part, PERIODIC, runtime_error(), skin, time_step, CellStructure::type, and DomainDecomposition::use_vList.

Referenced by maggs_init().

int maggs_set_parameters ( double  bjerrum,
double  f_mass,
int  mesh,
int  finite_epsilon_flag,
double  epsilon_infty 
)

called from: initialize.c

set the main parameters for the algorithm.

Parameters:
bjerrumBjerrum length for the system
f_massparameter to tune the speed of light (1/c^2)
meshMesh size in one dimension
finite_epsilon_flagwhether to do epsilon-at-infinity-correction
epsilon_inftyepsilon-at-infinity

Definition at line 531 of file maggs.c.

References MAGGS_struct::bjerrum, MAGGS_struct::epsilon_infty, ES_OK, MAGGS_struct::f_mass, MAGGS_struct::finite_epsilon_flag, MAGGS_struct::invsqrt_f_mass, MAGGS_struct::mesh, and mpi_bcast_coulomb_params().

Referenced by tclcommand_inter_coulomb_parse_maggs().

void maggs_setup_local_lattice ( )

Set up lattice, calculate dimensions and lattice parameters Allocate memory for lattice sites and fields.

inner left down grid point (global index)

inner up right grid point (global index)

correct roundof errors at boundary

inner grid dimensions

spacial position of left down grid point

spacial position of upper right grid point

left down margin

up right margin

reduce inner grid indices from global to local

allocate memory for sites and neighbors

set up lattice sites

Definition at line 624 of file maggs.c.

References MAGGS_struct::a, Bfield, Dfield, FOR3D, FORALL_SITES, i, MAGGS_struct::inva, iy, lattice, lparams, maggs_get_linear_index(), maggs_setup_neighbors(), malloc, my_left, my_right, neighbor, and ROUND_ERROR_PREC.

Referenced by maggs_init().

void maggs_setup_neighbors ( )

sets up nearest neighbors for each site in linear index

Definition at line 554 of file maggs.c.

References iy, lparams, maggs_get_linear_index(), neighbor, XMINUS, XPLUS, YMINUS, YPLUS, ZMINUS, and ZPLUS.

Referenced by maggs_setup_local_lattice().

void maggs_update_charge_gradients ( double *  grad)

finds correct lattice cube for particles.

calculates charge gradients on this cube.

Parameters:
gradgradient array to write into

Definition at line 1078 of file maggs.c.

References CellPList::cell, FOR3D, i, MAGGS_struct::inva, local_cells, lparams, maggs_calc_charge_gradients(), CellPList::n, ParticleList::n, ParticlePosition::p, ParticleList::part, Particle::r, and SPACE_DIM.

Referenced by maggs_calc_forces().

void maggs_update_plaquette ( int  mue,
int  nue,
int *  Neighbor,
int  index,
double  delta 
)

updates all D-fields on links of the plaquette and the surroundings.

delta was calculated before in function "maggs_perform_rot_move_inplane".

Parameters:
muedirection 1 of update
nuedirection 2 of update
Neighborneighbor lattice site
indexindex of current lattice site
deltaby which amount to update field

Definition at line 390 of file maggs.c.

References Dfield, and i.

Referenced by maggs_perform_rot_move_inplane().


Variable Documentation

double* Bfield [static]
double* Dfield [static]
t_site* lattice [static]
lattice_parameters lparams [static]
MAGGS_struct maggs = { 1, 1.0, 0. , 0. , 0. , 0. , 0. , 0 , 0. , 0. , {{0.},{0.}}}

Definition at line 157 of file maggs.c.

Referenced by mpi_bcast_coulomb_params_slave(), and tclprint_to_result_Maggs().

t_dirs* neighbor [static]