![]() |
ESPResSo 3.2.0-11-g9950804-git
Extensible Simulation Package for Soft Matter Research
|
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"
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: (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: 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 (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 (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_dirs * | neighbor |
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 FOR3D | ( | dir | ) | for(dir=0; dir<SPACE_DIM; dir++) |
Definition at line 94 of file maggs.c.
Referenced by calc_part_self_force(), maggs_accumulate_charge_from_ghosts(), maggs_add_current_on_segment(), maggs_calc_charge_gradients(), maggs_calc_forces(), maggs_calc_init_e_field(), maggs_calc_part_link_forces(), maggs_calc_self_influence(), maggs_couple_current_to_Dfield(), maggs_distribute_particle_charges(), maggs_electric_energy(), maggs_interpolate_charge(), maggs_minimize_transverse_field(), maggs_sanity_checks(), maggs_setup_local_lattice(), and maggs_update_charge_gradients().
| #define FORALL_INNER_SITES | ( | i, | |
| j, | |||
| k | |||
| ) |
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, | |||
| k | |||
| ) |
| #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 |
Definition at line 81 of file maggs.c.
Referenced by calc_part_self_force(), calc_self_energy_coeffs(), maggs_accumulate_charge_from_ghosts(), maggs_add_current_on_segment(), maggs_calc_forces(), maggs_calc_init_e_field(), maggs_calc_part_link_forces(), maggs_calc_self_influence(), maggs_distribute_particle_charges(), maggs_interpolate_charge(), and maggs_update_charge_gradients().
| #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().
| void calc_part_self_force | ( | Particle * | p | ) |
new self force correction with lattice Green's function.
| p | Particle 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 | ||
| ) |
loop over all cells and call charge current functions
| p | Particle pointer |
| ghost_cell | flag if cell is ghost cell |
Definition at line 1753 of file maggs.c.
References FOR3D, ParticleProperties::identity, MAGGS_struct::inva, lparams, Particle::m, maggs_calc_charge_fluxes_1D(), maggs_calc_e_field_on_link_1D(), maggs_check_intersect_1D(), maggs_get_linear_index(), ParticlePosition::p, Particle::p, ParticleProperties::q, Particle::r, SPACE_DIM, and ParticleMomentum::v.
Referenced by maggs_couple_current_to_Dfield().
| void maggs_add_transverse_field | ( | double | dt | ) |
calculate D-field from B-field according to
(and prefactors)
| dt | MD 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".
| q | charge of the moving particle |
| help | the relative position in the cube to the opposite of left down front lattice site. |
| flux | flux variable to write into |
| dir | direction 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:
| rel | 3dim-array of relative position in cube, |
| q | charge, |
| grad | huge 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:
(and prefactors plus current) The given "double* field" should be a B-Field!!
| mue | direction 1 of plane to rotate in |
| nue | direction 2 of plane to rotate in |
| field | input B-field |
| Neighbor | neighbor lattice site |
| index | index 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.
| j | given first direction |
| dir1 | write second direction into |
| dir2 | write 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:
The given "double* field" should be a D-Field!!
| mue | direction 1 of plane to rotate in |
| nue | direction 2 of plane to rotate in |
| field | input D-field |
| Neighbor | neighbor lattice site |
| index | index 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
| index | index of lattice site |
| flux | charge flux in lattice site |
| v | speed of particle |
| dir | first 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 | ( | ) |
Public function.
Calculate the forces on all particles.
Calculates the actual force on each particle by calling all other needed functions (except for maggs_propagate_B_field)
Definition at line 2195 of file maggs.c.
References CellPList::cell, cells_get_n_particles(), MAGGS_struct::finite_epsilon_flag, FOR3D, i, MAGGS_struct::inva, local_cells, lparams, maggs_add_transverse_field(), maggs_calc_part_link_forces(), maggs_calc_self_influence(), maggs_compute_dipole_correction(), maggs_couple_current_to_Dfield(), maggs_get_linear_index(), MAGGS_TRACE, maggs_update_charge_gradients(), CellPList::n, ParticleList::n, ParticlePosition::p, Particle::p, ParticleList::part, ParticleProperties::q, Particle::r, realloc, SPACE_DIM, and time_step.
Referenced by calc_long_range_forces().
| void maggs_calc_init_e_field | ( | ) |
calculates initial electric field configuration.
currently uses simple and slow method of plaquettes and links. energy minimization takes up lots of time.
Definition at line 1324 of file maggs.c.
References CELL_GLOBAL_EXCHANGE, cells_resort_particles(), comm_cart, Dfield, FOR3D, FORALL_INNER_SITES, i, MAGGS_struct::inva, iy, lattice, lparams, maggs_check_curl_E(), maggs_distribute_particle_charges(), maggs_exchange_surface_patch(), maggs_get_linear_index(), maggs_minimize_transverse_field(), MAGGS_TRACE, MAGGS_struct::mesh, MPI_Allreduce(), MPI_Comm_free(), MPI_Comm_split(), MPI_DOUBLE, MPI_Recv(), MPI_Send(), MPI_SUM, n_nodes, neighbor, node_grid, node_neighbors, node_pos, MAGGS_struct::prefactor, REQ_MAGGS_EQUIL, ROUND_ERROR_PREC, SPACE_DIM, SQR(), this_node, XMINUS, XPLUS, YMINUS, YPLUS, ZMINUS, and ZPLUS.
Referenced by maggs_init().
| void maggs_calc_part_link_forces | ( | Particle * | p, |
| int | index, | ||
| double * | grad | ||
| ) |
Calculate the actual force from the E-Field.
| p | Particle pointer |
| index | index of the lattice site |
| grad | charge 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.
| P | Particle 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.
| surface_patch | the 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:
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#.
| delta | amount by which the particle moves |
| r_new | current position of particle |
| dir | direction in which to check for intersection |
| first | position of particle within lattice cube |
| t_step | time step |
| identity | particle 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 | ( | ) |
Definition at line 479 of file maggs.c.
References box_l, CellPList::cell, comm_cart, MAGGS_struct::epsilon_infty, Particle::f, i, local_cells, M_PI, MPI_Allreduce(), MPI_DOUBLE, MPI_SUM, CellPList::n, ParticleList::n, Particle::p, ParticleList::part, and ParticleProperties::q.
Referenced by maggs_calc_forces().
| int maggs_count_charged_particles | ( | ) |
Counts the total number of charged particles on all processors.
Count the number of charges in the whole 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.
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.
| field | Field to communicate. Can be B- or D-field. |
| dim | Dimension in which to communicate |
| e_equil | Flag 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 | ( | ) |
| 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!!!
| x | index in x direction |
| y | index in y direction |
| z | index in z direction |
| latticedim | dimensions of the lattice |
Definition at line 263 of file maggs.c.
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.
| index_shift | amount to move in direction |
| index_base | index of base on current processor |
| axes | in which direction to move |
| adim | dimensions 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.
| x | relative 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.
| first | 3dim-array lattice position, |
| rel | 3dim-array relative position in cube, |
| q | charge 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.
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.
| i | index of the current lattice site |
| n | coordinate, 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
(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.
| dt | time 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.
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.
| bjerrum | Bjerrum length for the system |
| f_mass | parameter to tune the speed of light (1/c^2) |
| mesh | Mesh size in one dimension |
| finite_epsilon_flag | whether to do epsilon-at-infinity-correction |
| epsilon_infty | epsilon-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 | ( | ) |
| void maggs_update_charge_gradients | ( | double * | grad | ) |
finds correct lattice cube for particles.
calculates charge gradients on this cube.
| grad | gradient 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".
| mue | direction 1 of update |
| nue | direction 2 of update |
| Neighbor | neighbor lattice site |
| index | index of current lattice site |
| delta | by which amount to update field |
Definition at line 390 of file maggs.c.
Referenced by maggs_perform_rot_move_inplane().
double* Bfield [static] |
Definition at line 166 of file maggs.c.
Referenced by maggs_add_transverse_field(), maggs_exit(), maggs_magnetic_energy(), maggs_propagate_B_field(), and maggs_setup_local_lattice().
double* Dfield [static] |
Definition at line 164 of file maggs.c.
Referenced by maggs_add_transverse_field(), maggs_calc_e_field_on_link_1D(), maggs_calc_init_e_field(), maggs_calc_part_link_forces(), maggs_check_curl_E(), maggs_electric_energy(), maggs_exit(), maggs_minimize_transverse_field(), maggs_perform_rot_move_inplane(), maggs_propagate_B_field(), maggs_setup_local_lattice(), and maggs_update_plaquette().
t_site* lattice [static] |
Definition at line 162 of file maggs.c.
Referenced by maggs_calc_e_field_on_link_1D(), maggs_calc_init_e_field(), maggs_calc_part_link_forces(), maggs_distribute_particle_charges(), maggs_electric_energy(), maggs_exit(), maggs_interpolate_charge(), and maggs_setup_local_lattice().
lattice_parameters lparams [static] |
Definition at line 160 of file maggs.c.
Referenced by maggs_accumulate_charge_from_ghosts(), maggs_add_current_on_segment(), maggs_add_transverse_field(), maggs_calc_e_field_on_link_1D(), maggs_calc_forces(), maggs_calc_init_e_field(), maggs_calc_part_link_forces(), maggs_calc_self_influence(), maggs_calc_surface_patches(), maggs_check_curl_E(), maggs_couple_current_to_Dfield(), maggs_distribute_particle_charges(), maggs_electric_energy(), maggs_interpolate_charge(), maggs_magnetic_energy(), maggs_minimize_transverse_field(), maggs_propagate_B_field(), maggs_setup_local_lattice(), maggs_setup_neighbors(), and maggs_update_charge_gradients().
| 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().
Definition at line 168 of file maggs.c.
Referenced by build_verlet_lists(), build_verlet_lists_and_calc_verlet_ia(), build_verlet_lists_and_calc_verlet_ia_iccp3m(), calc_link_cell(), calc_link_cell_iccp3m(), calculate_link_cell_energies(), calculate_link_cell_virials(), maggs_add_transverse_field(), maggs_calc_e_field_on_link_1D(), maggs_calc_init_e_field(), maggs_calc_part_link_forces(), maggs_check_curl_E(), maggs_exit(), maggs_interpolate_charge(), maggs_perform_rot_move_inplane(), maggs_propagate_B_field(), maggs_setup_local_lattice(), and maggs_setup_neighbors().
1.7.5.1