Skip to content

Commit 3bb5803

Browse files
authored
Merge pull request microhh#292 from bartvstratum/develop_dust
Renamed `dust` to `particle_bin`.
2 parents fca544e + 6ec83d2 commit 3bb5803

File tree

10 files changed

+82
-79
lines changed

10 files changed

+82
-79
lines changed
File renamed without changes.

cases/dust_settling/dust.ini.base renamed to cases/drycblles_particle_bin/particle_bin.ini.base

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,10 +57,10 @@ flow_direction[north]=outflow
5757
flow_direction[east]=outflow
5858
flow_direction[south]=outflow
5959

60-
[dust]
61-
swdust=1
62-
dustlist=None
63-
w_terminal=None
60+
[particle_bin]
61+
sw_particle=1
62+
particle_list=None
63+
w_particle=None
6464

6565
[fields]
6666
visc=1.e-5

cases/dust_settling/dust_input.py renamed to cases/drycblles_particle_bin/particle_bin_input.py

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
"""
1010
float_type = np.float32 # np.float32 for -USESP=true, else np.float64.
1111

12-
dust_bins = np.array([0, 2, 10, 20, 58, 83, 440]) # (μm)
12+
particle_bins = np.array([0, 2, 10, 20, 58, 83, 440]) # (μm)
1313

1414
xsize = 12800
1515
ysize = 6400
@@ -42,10 +42,10 @@
4242

4343
# All scalars start at concentration zero, with
4444
# inflow of air with concentration zero at lateral boundaries.
45-
dust_list = [f'{dust_bins[i]}-{dust_bins[i+1]}um' for i in range(dust_bins.size - 1)]
45+
particle_list = [f'{particle_bins[i]}-{particle_bins[i+1]}um' for i in range(particle_bins.size - 1)]
4646

4747
scalars = {}
48-
for scalar in dust_list:
48+
for scalar in particle_list:
4949
scalars[scalar] = np.zeros(ktot)
5050

5151

@@ -58,9 +58,9 @@
5858
nu = 1e-5 # Kinematic viscosity air [m2 s-1]
5959
g = 9.81 # Gravitational acceleration [m s-2]
6060

61-
dust_diameter = 0.5*(dust_bins[1:] + dust_bins[:-1]) * 1e-6
61+
particle_diameter = 0.5*(particle_bins[1:] + particle_bins[:-1]) * 1e-6
6262

63-
tau_p = dust_diameter**2 * rho_p / (18 * nu * rho_a)
63+
tau_p = particle_diameter**2 * rho_p / (18 * nu * rho_a)
6464
w_terminal = -tau_p * g
6565

6666
# Create circular field with dust emissions.
@@ -74,14 +74,14 @@
7474

7575
field_flux = np.zeros((jtot, itot), dtype=float_type)
7676
field_flux[field_mask] = 1.
77-
for scalar in dust_list:
77+
for scalar in particle_list:
7878
field_flux.tofile('{}_bot_in.0000000'.format(scalar))
7979

8080

8181
"""
8282
Set/write new namelist.
8383
"""
84-
ini = mht.Read_namelist('dust.ini.base')
84+
ini = mht.Read_namelist('particle_bin.ini.base')
8585

8686
ini['grid']['itot'] = itot
8787
ini['grid']['jtot'] = jtot
@@ -95,23 +95,23 @@
9595

9696
ini['time']['endtime'] = endtime
9797

98-
ini['fields']['slist'] = dust_list
99-
ini['advec']['fluxlimit_list'] = dust_list
100-
ini['limiter']['limitlist'] = dust_list
101-
ini['boundary']['scalar_outflow'] = dust_list
102-
ini['boundary']['sbot_2d_list'] = dust_list
98+
ini['fields']['slist'] = particle_list
99+
ini['advec']['fluxlimit_list'] = particle_list
100+
ini['limiter']['limitlist'] = particle_list
101+
ini['boundary']['scalar_outflow'] = particle_list
102+
ini['boundary']['sbot_2d_list'] = particle_list
103103

104-
ini['dust']['dustlist'] = dust_list
105-
for i in range(len(dust_list)):
106-
ini['dust'][f'w_terminal[{dust_list[i]}]'] = w_terminal[i]
104+
ini['particle_bin']['particle_list'] = particle_list
105+
for i in range(len(particle_list)):
106+
ini['particle_bin'][f'w_particle[{particle_list[i]}]'] = w_terminal[i]
107107

108108
# Statistics/crosses/...
109-
scalar_crosses = dust_list + [s+'_path' for s in dust_list]
109+
scalar_crosses = particle_list + [s+'_path' for s in particle_list]
110110
ini['cross']['crosslist'] = scalar_crosses + ['th', 'u', 'v', 'w']
111111
ini['cross']['xz'] = y0
112112
ini['cross']['yz'] = x0
113113

114-
ini.save('dust.ini', allow_overwrite=True)
114+
ini.save('particle_bin.ini', allow_overwrite=True)
115115

116116

117117
"""
@@ -121,7 +121,7 @@ def add_var(name, dims, values, nc_group):
121121
nc_var = nc_group.createVariable(name, float_type, dims)
122122
nc_var[:] = values
123123

124-
nc_file = nc.Dataset('dust_input.nc', mode='w', datamodel='NETCDF4')
124+
nc_file = nc.Dataset('particle_bin_input.nc', mode='w', datamodel='NETCDF4')
125125
nc_file.createDimension('z', ktot)
126126
add_var('z', ('z'), z, nc_file)
127127

cases/dust_settling/plot_sedimentation_velocity.py renamed to cases/drycblles_particle_bin/plot_sedimentation_velocity.py

File renamed without changes.
File renamed without changes.

include/model.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ template<typename> class Pres;
4646
template<typename> class Force;
4747
template<typename> class Aerosol;
4848
template<typename> class Background;
49-
template<typename> class Dust;
49+
template<typename> class Particle_bin;
5050
template<typename> class Thermo;
5151
template<typename> class Microphys;
5252
template<typename> class Radiation;
@@ -107,7 +107,8 @@ class Model
107107
std::shared_ptr<Decay<TF>> decay;
108108
std::shared_ptr<Limiter<TF>> limiter;
109109
std::shared_ptr<Source<TF>> source;
110-
std::shared_ptr<Dust<TF>> dust;
110+
111+
std::shared_ptr<Particle_bin<TF>> particle_bin;
111112

112113
std::shared_ptr<Stats<TF>> stats;
113114
std::shared_ptr<Budget<TF>> budget;

include/dust.h renamed to include/particle_bin.h

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@
2020
* along with MicroHH. If not, see <http://www.gnu.org/licenses/>.
2121
*/
2222

23-
#ifndef DUST_H
24-
#define DUST_H
23+
#ifndef PARTICLE_BIN_H
24+
#define PARTICLE_BIN_H
2525

2626
class Master;
2727
class Input;
@@ -31,11 +31,11 @@ template<typename> class Stats;
3131
template<typename> class Timeloop;
3232

3333
template<typename TF>
34-
class Dust
34+
class Particle_bin
3535
{
3636
public:
37-
Dust(Master&, Grid<TF>&, Fields<TF>&, Input&);
38-
~Dust();
37+
Particle_bin(Master&, Grid<TF>&, Fields<TF>&, Input&);
38+
~Particle_bin();
3939

4040
void exec(Stats<TF>&);
4141
void create(Timeloop<TF>&);
@@ -46,11 +46,11 @@ class Dust
4646
Grid<TF>& grid;
4747
Fields<TF>& fields;
4848

49-
bool sw_dust;
49+
bool sw_particle;
5050
TF cfl_max;
5151
unsigned long idt_max;
5252

5353
// Gravitational settling velocities, negative downward.
54-
std::map<std::string, TF> w_terminal;
54+
std::map<std::string, TF> w_particle;
5555
};
5656
#endif

src/model.cxx

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
#include "diff.h"
4343
#include "pres.h"
4444
#include "force.h"
45-
#include "dust.h"
45+
#include "particle_bin.h"
4646
#include "thermo.h"
4747
#include "radiation.h"
4848
#include "microphys.h"
@@ -141,10 +141,11 @@ Model<TF>::Model(Master& masterin, int argc, char *argv[]) :
141141
decay = std::make_shared<Decay <TF>>(master, *grid, *fields, *input);
142142
limiter = std::make_shared<Limiter<TF>>(master, *grid, *fields, *diff, *input);
143143
source = std::make_shared<Source <TF>>(master, *grid, *fields, *input);
144-
dust = std::make_shared<Dust <TF>>(master, *grid, *fields, *input);
145144
aerosol = std::make_shared<Aerosol<TF>>(master, *grid, *fields, *input);
146145
background= std::make_shared<Background<TF>>(master, *grid, *fields, *input);
147146

147+
particle_bin = std::make_shared<Particle_bin<TF>>(master, *grid, *fields, *input);
148+
148149
ib = std::make_shared<Immersed_boundary<TF>>(master, *grid, *fields, *input);
149150

150151
stats = std::make_shared<Stats <TF>>(master, *grid, *soil_grid, *background, *fields, *advec, *diff, *input);
@@ -267,7 +268,7 @@ void Model<TF>::load()
267268
buffer->create(*input, *input_nc, *stats);
268269
force->create(*input, *input_nc, *stats);
269270
source->create(*input, *input_nc);
270-
dust->create(*timeloop);
271+
particle_bin->create(*timeloop);
271272
aerosol->create(*input, *input_nc, *stats);
272273
background->create(*input, *input_nc, *stats);
273274

@@ -417,8 +418,8 @@ void Model<TF>::exec()
417418
// Add point and line sources of scalars.
418419
source->exec(*timeloop);
419420

420-
// Gravitational settling of dust.
421-
dust->exec(*stats);
421+
// Gravitational settling of binned dust types.
422+
particle_bin->exec(*stats);
422423

423424
// Apply the large scale forcings. Keep this one always right before the pressure.
424425
force->exec(timeloop->get_sub_time_step(), *thermo, *stats);
@@ -765,16 +766,16 @@ void Model<TF>::set_time_step()
765766

766767
// Retrieve the maximum allowed time step per class.
767768
timeloop->set_time_step_limit();
768-
timeloop->set_time_step_limit(advec ->get_time_limit(timeloop->get_idt(), timeloop->get_dt()));
769-
timeloop->set_time_step_limit(diff ->get_time_limit(timeloop->get_idt(), timeloop->get_dt()));
770-
timeloop->set_time_step_limit(thermo ->get_time_limit(timeloop->get_idt(), timeloop->get_dt()));
771-
timeloop->set_time_step_limit(microphys->get_time_limit(timeloop->get_idt(), timeloop->get_dt()));
772-
timeloop->set_time_step_limit(radiation->get_time_limit(timeloop->get_itime()));
773-
timeloop->set_time_step_limit(stats ->get_time_limit(timeloop->get_itime()));
774-
timeloop->set_time_step_limit(cross ->get_time_limit(timeloop->get_itime()));
775-
timeloop->set_time_step_limit(dump ->get_time_limit(timeloop->get_itime()));
776-
timeloop->set_time_step_limit(column ->get_time_limit(timeloop->get_itime()));
777-
timeloop->set_time_step_limit(dust ->get_time_limit());
769+
timeloop->set_time_step_limit(advec ->get_time_limit(timeloop->get_idt(), timeloop->get_dt()));
770+
timeloop->set_time_step_limit(diff ->get_time_limit(timeloop->get_idt(), timeloop->get_dt()));
771+
timeloop->set_time_step_limit(thermo ->get_time_limit(timeloop->get_idt(), timeloop->get_dt()));
772+
timeloop->set_time_step_limit(microphys ->get_time_limit(timeloop->get_idt(), timeloop->get_dt()));
773+
timeloop->set_time_step_limit(radiation ->get_time_limit(timeloop->get_itime()));
774+
timeloop->set_time_step_limit(stats ->get_time_limit(timeloop->get_itime()));
775+
timeloop->set_time_step_limit(cross ->get_time_limit(timeloop->get_itime()));
776+
timeloop->set_time_step_limit(dump ->get_time_limit(timeloop->get_itime()));
777+
timeloop->set_time_step_limit(column ->get_time_limit(timeloop->get_itime()));
778+
timeloop->set_time_step_limit(particle_bin->get_time_limit());
778779

779780
// Set the time step.
780781
timeloop->set_time_step();

src/dust.cu renamed to src/particle_bin.cu

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -22,17 +22,17 @@
2222

2323
#include "grid.h"
2424
#include "fields.h"
25-
#include "dust.h"
25+
#include "particle_bin.h"
2626
#include "tools.h"
2727

2828
namespace
2929
{
3030
template<typename TF> __global__
31-
void settle_dust_g(
31+
void settle_particles_g(
3232
TF* const __restrict__ st,
3333
const TF* const __restrict__ s,
3434
const TF* const __restrict__ dzhi,
35-
const TF w_terminal,
35+
const TF w_particles,
3636
const int istart, const int iend,
3737
const int jstart, const int jend,
3838
const int kstart, const int kend,
@@ -46,16 +46,16 @@ namespace
4646
if (i < iend && j < jend && k < kend)
4747
{
4848
const int ijk = i + j*jstride + k*kstride;
49-
st[ijk] -= w_terminal * (s[ijk+kstride]-s[ijk])*dzhi[k+1];
49+
st[ijk] -= w_particles * (s[ijk+kstride]-s[ijk])*dzhi[k+1];
5050
}
5151
}
5252
}
5353

5454
#ifdef USECUDA
5555
template<typename TF>
56-
void Dust<TF>::exec(Stats<TF>& stats)
56+
void Particle_bin<TF>::exec(Stats<TF>& stats)
5757
{
58-
if (!sw_dust)
58+
if (!sw_particle)
5959
return;
6060

6161
auto& gd = grid.get_grid_data();
@@ -68,8 +68,8 @@ void Dust<TF>::exec(Stats<TF>& stats)
6868
dim3 gridGPU(gridi, gridj, gd.ktot);
6969
dim3 blockGPU(blocki, blockj, 1);
7070

71-
for (auto& w : w_terminal)
72-
settle_dust_g<TF><<<gridGPU, blockGPU>>>(
71+
for (auto& w : w_particle)
72+
settle_particles_g<TF><<<gridGPU, blockGPU>>>(
7373
fields.st.at(w.first)->fld_g,
7474
fields.sp.at(w.first)->fld_g,
7575
gd.dzhi_g,
@@ -84,7 +84,7 @@ void Dust<TF>::exec(Stats<TF>& stats)
8484
#endif
8585

8686
#ifdef FLOAT_SINGLE
87-
template class Dust<float>;
87+
template class Particle_bin<float>;
8888
#else
89-
template class Dust<double>;
89+
template class Particle_bin<double>;
9090
#endif

0 commit comments

Comments
 (0)