def cellular_attributes(self, positions): n = positions.shape[1] cell_origin = positions.astype(dtype=np.int64) position_in_cell = positions - np.floor(positions) cell_id = np.empty(n, dtype=np.int64) Numba.cell_id(cell_id, cell_origin, self.strides) return cell_id, cell_origin, position_in_cell
def moments(moment_0, moments, n, attr, cell_id, idx, length, specs_idx, specs_rank, min_x, max_x, x_id): # TODO print("Numba import!: ThrustRTC.moments(...)") from PySDM.backends.numba.numba import Numba host_moment_0 = moment_0.to_ndarray() host_moments = moments.to_ndarray() host_n = n.to_ndarray() host_attr = attr.to_ndarray() host_cell_id = cell_id.to_ndarray() host_idx = idx.to_ndarray() host_specs_idx = specs_idx.to_ndarray() host_specs_rank = specs_rank.to_ndarray() Numba.moments_body(host_moment_0, host_moments, host_n, host_attr, host_cell_id, host_idx, length, host_specs_idx, host_specs_rank, min_x, max_x, x_id) moment_0.upload(host_moment_0) moments.upload(host_moments)
def moments(moment_0, moments, n, attr, cell_id, idx, length, specs_idx, specs_rank, min_x, max_x, x_id): # TODO print("Numba import!: ThrustRTC.moments(...)") from PySDM.backends.numba.numba import Numba from PySDM.backends.thrustRTC._storage_methods import StorageMethods host_moment_0 = StorageMethods.to_ndarray(moment_0) host_moments = StorageMethods.to_ndarray(moments) host_n = StorageMethods.to_ndarray(n) host_attr = StorageMethods.to_ndarray(attr) host_cell_id = StorageMethods.to_ndarray(cell_id) host_idx = StorageMethods.to_ndarray(idx) host_specs_idx = StorageMethods.to_ndarray(specs_idx) host_specs_rank = StorageMethods.to_ndarray(specs_rank) Numba.moments(host_moment_0, host_moments, host_n, host_attr, host_cell_id, host_idx, length, host_specs_idx, host_specs_rank, min_x, max_x, x_id) device_moment_0 = StorageMethods.from_ndarray(host_moment_0) device_moments = StorageMethods.from_ndarray(host_moments) trtc.Copy(device_moment_0, moment_0) trtc.Copy(device_moments, moments)
def __call__(self, t, y): rhod = y[idx_rhod] thd = y[idx_thd] qv = y[idx_qv] rw = y[idx_rw:] T, p, RH = Numba.temperature_pressure_RH(rhod, thd, qv) dy_dt = np.empty_like(y) foo(dy_dt, rw, T, p, self.n, RH, self.kappa, self.rd, qv, self.drhod_dt, self.dthd_dt, self.dqv_dt, self.m_d) return dy_dt
def shuffle(data, length, axis): from PySDM.backends.numba.numba import Numba host_arr = ThrustRTC.to_ndarray(data) Numba.shuffle(host_arr, length, axis=axis) dvce_arr = ThrustRTC.from_ndarray(host_arr) trtc.Copy(dvce_arr, data)
def shuffle(data, length, axis): from PySDM.backends.numba.numba import Numba host_arr = StorageMethods.to_ndarray(data) Numba.shuffle_global(host_arr, length) dvce_arr = StorageMethods.from_ndarray(host_arr) trtc.Copy(dvce_arr, data)
# noinspection PyProtectedMember from PySDM.backends.numba import _physics_methods as physics from PySDM.backends.numba.numba import Numba from PySDM.simulation.physics import constants as const import numpy as np backend = Numba() dr_dt_MM = backend.dr_dt_MM R = physics.R r_cr = physics.r_cr pvs = physics.pvs lv = physics.lv c_p = physics.c_p def th_dry(th_std, qv): return th_std * np.power(1 + qv / const.eps, const.Rd / const.c_pd) def th_std(p, T): return T * (const.p1000 / p)**(const.Rd / const.c_pd) def radius(volume): return (volume * 3 / 4 / np.pi) ** (1 / 3) def volume(radius): return 4 / 3 * np.pi * radius ** 3