def __init__(self, setup): t_half = setup.z_half / setup.w_avg dt = (2 * t_half) / setup.n_steps self.particles = Particles(backend=setup.backend, n_sd=1, dt=dt) self.particles.set_mesh_0d() self.particles.set_environment( MoistLagrangianParcelAdiabatic, { "mass_of_dry_air": setup.mass_of_dry_air, "p0": setup.p0, "q0": setup.q0, "T0": setup.T0, "w": setup.w }) r_dry = np.array([setup.r_dry]) x_dry = phys.volume(radius=r_dry) n = np.array([setup.n_in_dv], dtype=np.int64) r_wet = r_wet_init(r_dry, self.particles.environment, np.zeros_like(n), setup.kappa) v_wet = phys.volume(radius=r_wet) self.particles.create_state_0d(n=n, extensive={ 'dry volume': x_dry, 'volume': v_wet }, intensive={}) self.particles.add_dynamic(Condensation, {"kappa": setup.kappa}) self.n_steps = setup.n_steps
def __init__(self, setup): t_half = setup.z_half / setup.w_avg dt_output = (2 * t_half) / setup.n_steps self.n_substeps = 1 while dt_output / self.n_substeps >= setup.dt_max: # TODO dt_max self.n_substeps += 1 particles_builder = ParticlesBuilder(backend=setup.backend, n_sd=1, dt=dt_output / self.n_substeps) particles_builder.set_mesh_0d() particles_builder.set_environment(MoistLagrangianParcelAdiabatic, { "mass_of_dry_air": setup.mass_of_dry_air, "p0": setup.p0, "q0": setup.q0, "T0": setup.T0, "w": setup.w }) r_dry = np.array([setup.r_dry]) x_dry = phys.volume(radius=r_dry) n = np.array([setup.n_in_dv], dtype=np.int64) r_wet = r_wet_init(r_dry, particles_builder.particles.environment, np.zeros_like(n), setup.kappa) v_wet = phys.volume(radius=r_wet) particles_builder.create_state_0d(n=n, extensive={'dry volume': x_dry, 'volume': v_wet}, intensive={}) particles_builder.register_dynamic(Condensation, { "kappa": setup.kappa, "scheme": setup.scheme, "rtol_lnv": setup.rtol_lnv, "rtol_thd": setup.rtol_thd, }) self.particles = particles_builder.get_particles() self.n_steps = setup.n_steps
def create_state_2d(self, extensive, intensive, spatial_discretisation, spectral_discretisation, spectrum_per_mass_of_dry_air, r_range, kappa, radius_threshold): assert_not_none(self.particles.mesh, self.particles.environment) assert_none(self.particles.state) with np.errstate(all='raise'): positions = spatial_discretisation(self.particles.mesh.grid, self.particles.n_sd) cell_id, cell_origin, position_in_cell = self.particles.mesh.cellular_attributes( positions) r_dry, n_per_kg = spectral_discretisation( self.particles.n_sd, spectrum_per_mass_of_dry_air, r_range) r_wet = r_wet_init(r_dry, self.particles.environment, cell_id, kappa) n_per_m3 = n_init(n_per_kg, self.particles.environment, self.particles.mesh, cell_id) n = discretise_n(n_per_m3) extensive['volume'] = phys.volume(radius=r_wet) extensive['dry volume'] = phys.volume(radius=r_dry) self.particles.state = StateFactory.state(n, intensive, extensive, cell_id, cell_origin, position_in_cell, self.particles) for product in [ TotalParticleConcentration(self.particles), TotalParticleSpecificConcentration(self.particles), AerosolConcentration(self.particles, radius_threshold), AerosolSpecificConcentration(self.particles, radius_threshold), ParticleMeanRadius(self.particles), SuperDropletCount(self.particles) ]: self.register_product(product)
def __init__(self, setup): self.particles = Particles(backend=setup.backend, n_sd=setup.n_sd, dt=setup.dt) self.particles.set_mesh_0d() self.particles.set_environment( MoistLagrangianParcelAdiabatic, { "mass_of_dry_air": setup.mass_of_dry_air, "p0": setup.p0, "q0": setup.q0, "T0": setup.T0, "w": setup.w, "z0": setup.z0 }) v_dry = phys.volume(radius=setup.r_dry) r_wet = r_wet_init(setup.r_dry, self.particles.environment, np.zeros_like(setup.n), setup.kappa) v_wet = phys.volume(radius=r_wet) self.particles.create_state_0d(n=setup.n, extensive={ 'dry volume': v_dry, 'volume': v_wet }, intensive={}) self.particles.add_dynamic(Condensation, {"kappa": setup.kappa}) self.n_steps = setup.n_steps
def create_state_2d(self, extensive, intensive, spatial_discretisation, spectral_discretisation, spectrum_per_mass_of_dry_air, r_range, kappa): assert_not_none(self.mesh, self.environment) assert_none(self.state) with np.errstate(all='raise'): positions = spatial_discretisation(self.mesh.grid, self.n_sd) cell_id, cell_origin, position_in_cell = self.mesh.cellular_attributes(positions) r_dry, n_per_kg = spectral_discretisation(self.n_sd, spectrum_per_mass_of_dry_air, r_range) r_wet = r_wet_init(r_dry, self.environment, cell_id, kappa) n_per_m3 = n_init(n_per_kg, self, cell_id) n = discretise_n(n_per_m3) extensive['volume'] = phys.volume(radius=r_wet) extensive['dry volume'] = phys.volume(radius=r_dry) self.state = StateFactory.state(n, intensive, extensive, cell_id, cell_origin, position_in_cell, self)
def __init__(self, setup): dt_output = setup.total_time / setup.n_steps self.n_substeps = 1 while (dt_output / self.n_substeps >= setup.dt_max): self.n_substeps += 1 particles_builder = ParticlesBuilder(backend=setup.backend, n_sd=setup.n_sd, dt=dt_output / self.n_substeps) particles_builder.set_mesh_0d() particles_builder.set_environment( MoistLagrangianParcelAdiabatic, { "mass_of_dry_air": setup.mass_of_dry_air, "p0": setup.p0, "q0": setup.q0, "T0": setup.T0, "w": setup.w, "z0": setup.z0 }) v_dry = phys.volume(radius=setup.r_dry) r_wet = r_wet_init(setup.r_dry, particles_builder.particles.environment, np.zeros_like(setup.n), setup.kappa) v_wet = phys.volume(radius=r_wet) particles_builder.create_state_0d(n=setup.n, extensive={ 'dry volume': v_dry, 'volume': v_wet }, intensive={}) particles_builder.register_dynamic( Condensation, { "kappa": setup.kappa, "scheme": setup.condensation_scheme, "rtol_lnv": setup.rtol_lnv, "rtol_thd": setup.rtol_thd, }) self.particles = particles_builder.get_particles() self.n_steps = setup.n_steps