PySDM_examples.utils.basic_simulation

 1import numpy as np
 2
 3
 4class BasicSimulation:
 5    def __init__(self, particulator):
 6        self.particulator = particulator
 7
 8    def _save(self, output):
 9        for k, v in self.particulator.products.items():
10            value = v.get()
11            if isinstance(value, np.ndarray) and value.shape[0] == 1:
12                value = value[0]
13            output[k].append(value)
14
15    def _run(self, nt, steps_per_output_interval):
16        output = {k: [] for k in self.particulator.products}
17        self._save(output)
18        for _ in range(0, nt + 1, steps_per_output_interval):
19            self.particulator.run(steps=steps_per_output_interval)
20            self._save(output)
21        return output
class BasicSimulation:
 5class BasicSimulation:
 6    def __init__(self, particulator):
 7        self.particulator = particulator
 8
 9    def _save(self, output):
10        for k, v in self.particulator.products.items():
11            value = v.get()
12            if isinstance(value, np.ndarray) and value.shape[0] == 1:
13                value = value[0]
14            output[k].append(value)
15
16    def _run(self, nt, steps_per_output_interval):
17        output = {k: [] for k in self.particulator.products}
18        self._save(output)
19        for _ in range(0, nt + 1, steps_per_output_interval):
20            self.particulator.run(steps=steps_per_output_interval)
21            self._save(output)
22        return output
BasicSimulation(particulator)
6    def __init__(self, particulator):
7        self.particulator = particulator
particulator