py4mulas.mpi
modules
py4mulas.mpi.executors
- class py4mulas.mpi.executors.KspaceExecutor(k_vectors: MakeVectors | list[tuple[float]] | None = None, k_bounds: MakeBounds | tuple[tuple[float]] | None = None)[source]
Bases:
objectParallel execution over k_vectors or k_bounds
- k_vectors
The momentum vectors to be shared between workers, if not specified default model k_vectors are used.
- k_bounds
Initial bounds to be shared between workers, if not specified default model bounds are used.
Note
We recommand to use num of processors = m^dim when scipy integration is expected. When discrete kspace sum is to be performed, the splitting is anyway deterministic.
- __call__(fun)[source]
Call self as a function.
- property input_data
- property k_bounds
- property k_vectors
py4mulas.mpi.kspace_partitioner
- class py4mulas.mpi.kspace_partitioner.MakeBounds(model: Kmodel, centers: dict | None = None, size: int = 4)[source]
Bases:
objectMakes a list of bounds with focus at some particular centers in kspace. This works perfectly for periodically ordered centers within model’s kspace.
- model
An instance of
Kmodel
- centers
In the form {center:length}, with length being the half side-length of the box to be constructed around center. If centers is None, size will be used to uniformly split model’s bounds.
- size
The number of points per dimention. Corresponds ideally to the number of processors for which bounds are discretized.
Example
>>> centers = {(i, j):0.1 for i in range(-4, 5) for j in range(-3, 4)} >>> bounds = MakeBounds(model, centers, size=4) >>> bounds.view()
- class py4mulas.mpi.kspace_partitioner.MakeVectors(model: Kmodel, centers: dict, coarse_n: int | None = None)[source]
Bases:
objectMakes k_vectors of the a model considering centers where a denser discretization is required.
- model
An instance of
Kmodel
- centers
Contains the kpoints at which a zooming is wanted format: {coord:(side_length, n)} where n is the number of points along each direction
- coarse_n
Number of sampling points along each dimension of the coarse kspace grid. If not provided, available k_vectors are considered for coarse grid within which centers are discretized.
py4mulas.mpi.computers
- class py4mulas.mpi.computers.HamParamComputer(formula: KuboFormula, executor: KspaceExecutor, params: dict[str, list | numpy.ndarray], method: str = 'discrete', opts: dict | None = None)[source]
Bases:
_ComputerComputes a response formula using an
executorfor varied Hamiltonian params.- Parameters:
formula – An instance of
KuboFormulaexecutor – An instance of
KspaceExecutorparams – A dictionary containing the parameters to be changed. It should be in the form:
{'param1':[...], 'param2':[...]}.
Example
>>> params = {'param1':np.linspace(0, 1, 10), 'param2':[0, 1]} >>> result = py4mulas.mpi.computers.HamParamComputer(some_formula, some_executor, params)(mu=0, temperature=0, eta=0)
- __call__(mu: float = 0, temperature: float = 0, eta: float = 0) numpy.ndarray[source]
Gives the parallelly computed response formula at (\(\mu\), \(T\), \(\eta\))
- Parameters:
mu – Chemical potential \(\mu\)
temperature – System’s temperature
eta – Broadening \(\eta\)
- Returns:
The transport response as a 1d array ordered exactly as itertools.product(\(l_1\), \(l2\), …) with \(l_i\) being the list of values for the \(i\) th parameter in
params- Return type:
np.ndarray
- class py4mulas.mpi.computers.MuTEtaComputer(formula: KuboFormula, executor: KspaceExecutor, opts: dict | None = None, method: str = 'discrete')[source]
Bases:
_ComputerComputes a response formula using an
executorwith precomputation of the operator kernel for a set ofdata. The energy kernel is computed once for each set ofk_vectors. Therefore, the loop overdatais made cheap for each worker.- Parameters:
formula – An instance of
KuboFormulaexecutor – An instance of
KspaceExecutoropts – The options to be passed to scipy integrator
method – Either discrete for discrete sum or scipy for adaptive integration.
- __call__(mu: float | list = 0, temperature: float | list = 0, eta: float | list = 0) numpy.ndarray[source]
Executes parallelly a transport formula for a combunation of transport parameters (\(\mu\), \(T\), \(\eta\))
- Parameters:
mu – Chemical potential \(\mu\)
temperature – System’s temperature
eta – Broadening \(\eta\)
Example
>>> mu = np.linspace(0, 1, 10) >>> temperature = np.linspace(0, 1, 10) >>> eta = np.linspace(0, 0.1, 10) >>> result = py4mulas.mpi.computers.MuTEtaComputer(some_formula, some_executor)(mu, temperature, eta)
- Returns:
The transport response as a 1d array ordered exactly itertools.product(mu, temperature, eta). If these are all given as floats the result is an array containing a single element.
- Return type:
np.ndarray