coulomb_kmc.kmc_inject_extract module

Module to handle injection and extraction of charges from a PyFMM instance.

Currently implemented for 1 MPI rank only.

class coulomb_kmc.kmc_inject_extract.DiscoverInjectExtract(inject_sites, extract_sites, positions, extract_flag)

Bases: object

class to identify particles which are on sites where they can be extracted from and empty sites where particles can be injected.

Parameters
  • inject_sites – Tuple ((r_x, r_y, r_z),… where particles can be injected.

  • extract_sites – Tuple of positions where charges can be extracted from.

  • positions – PositionDat to use for particle positions.

  • extract_flagParticleDat(ncomp=1, dtype=INT64) to use for marking potential extractions.

class coulomb_kmc.kmc_inject_extract.InjectorExtractor

Bases: coulomb_kmc.common.ProfInc

Class to propose and accept the injection and extraction of charges. Is inherited by KMCFMM.

compute_energy(positions, charges)

Compute the energy of a set of charges in a domain. Assumes that the number of charges is small.

Parameters
  • positions – Nx3, c_double NumPy array of positiions.

  • charges – Nx1, c_double NumPy array of charge values.

extract(ids=())

Extract the set of charges given by local ids.

Parameters

ids – Iterable of particle local ids to remove.

get_energy(ids)

Get the energy of each charge in the iterable ids.

Parameters

ids – Local ids of charges.

get_energy_with_dats(masks, energy)

Get the current energy conribution of the charges with positive mask values.

Parameters
  • masks – ParticleDat(ncomp=1, dtype=c_int64) (Input) Indicate the relevant charges.

  • energy – ParticleDat(ncomp=1, dtype=c_double) (Output) Storage for energy contribution.

inject(add)

Inject a set of charges. e.g.

kmc = KMCFMM(....)
kmc.inject({
    A.P: np.array((
        (r_x1, r_y1, r_z1),
        (r_x2, r_y2, r_z2),
    )),
    A.Q: np.array(((-1.0), (1.0))),
    ..
})
Parameters

add – Dictonary of the style of state.modifier.add.

propose_extract(ids, self_energy=True)

Propose the extraction of a set of charges by providing the local particle ids. Returns the change of energy if the charges were removed.

Parameters

ids – Iterable of local charge id to remove.

propose_inject(positions, charges)

Propose the injection of a set of charges. Returns the change in system energy if the set of charges were added.

Parameters
  • positions – New charge positions.

  • charges – New charge values.