20 const Potentials &potentials,
const double time_step) {
22 if (fields_lat ==
nullptr || fields_lat->
when_update() != fields_lat_update) {
26 const std::array<int, 3> lattice_n_cells = fields_lat->
n_cells();
27 const int number_of_nodes =
28 lattice_n_cells[0] * lattice_n_cells[1] * lattice_n_cells[2];
35 for (
int i = 0; i < number_of_nodes; i++) {
48 for (
int i = 0; i < number_of_nodes; i++) {
50 double rhoB_at_i = ((*jmuB_lat)[i]).rho();
51 FourVector jmuB_at_i = ((*jmuB_lat)[i]).jmu_net();
53 double abs_rhoB_at_i = std::abs(rhoB_at_i);
61 const int sgn = rhoB_at_i > 0 ? 1 : -1;
64 double field_contribution = 0.0;
68 std::pow(abs_rhoB_at_i / rhoB_0, potentials.
powers()[j] - 2.0) /
71 FourVector field_at_i = field_contribution * jmuB_at_i;
74 ((*fields_lat)[i]).overwrite_A_mu(field_at_i);
81 for (
int i = 0; i < number_of_nodes; i++) {
89 *fields_four_grad_lattice);
92 for (
int i = 0; i < number_of_nodes; i++) {
93 auto tmp = (*fields_four_grad_lattice)[i];
94 ((*fields_lat)[i]).overwrite_dAmu_dxnu(tmp[0], tmp[1], tmp[2], tmp[3]);
The FourVector class holds relevant values in Minkowski spacetime with (+, −, −, −) metric signature.
A class that stores parameters of potentials, calculates potentials and their gradients.
const std::vector< double > & powers() const
const std::vector< double > & coeffs() const
int number_of_terms() const
double saturation_density() const
A container class to hold all the arrays on the lattice and access them.
void reset()
Sets all values on lattice to zeros.
LatticeUpdate when_update() const
void compute_four_gradient_lattice(RectangularLattice< FourVector > &old_lat, double time_step, RectangularLattice< std::array< FourVector, 4 >> &grad_lat) const
Compute a fourgradient on a lattice of FourVectors jmu via the finite difference method.
const std::array< int, 3 > & n_cells() const
void assign_value(int lattice_index, T value)
Overwrite with a template value T at a given node.
int sgn(T val)
Signum function.
constexpr double very_small_double
A very small double, used to avoid division by zero.
void update_fields_lattice(RectangularLattice< FieldsOnLattice > *fields_lat, RectangularLattice< FourVector > *old_fields, RectangularLattice< FourVector > *new_fields, RectangularLattice< std::array< FourVector, 4 >> *fields_four_grad_lattice, DensityLattice *jmu_B_lat, const LatticeUpdate fields_lat_update, const Potentials &potentials, const double time_step)
Updates the contents on the lattice of FieldsOnLattice type.
LatticeUpdate
Enumerator option for lattice updates.