18 new GenDict({{
"Atoms", atoms}, {
"Box", box}})));
24 const Vec<std::pair<ElPtr,ElPtr>> &pairs)
28 for (
const auto &pair : pairs)
31 new GenDict({{
"Atoms", pair.first}, {
"Box", pair.second}})));
46 auto el_atoms =
generators[index]->get_element(
"Atoms");
48 el_atoms->check_required_keys({
"x",
"y",
"z",
"radius"});
50 auto atoms = el_atoms->make_reduced_data({
"x",
"y",
"z",
"radius"});
52 auto el_box =
generators[index]->get_element(
"Box");
54 el_box->check_required_keys({
"lo_x",
"lo_y",
"hi_x",
"hi_y"});
56 auto &box = el_box->get_data();
58 auto origin_x = box[
"lo_x"].get<
double>();
59 auto origin_y = box[
"lo_y"].get<
double>();
60 auto delta_x = (box[
"hi_x"].get<
double>() - origin_x) / double(
nx);
61 auto delta_y = (box[
"hi_y"].get<
double>() - origin_y) / double(
ny);
65 origin_x += 0.5 * delta_x;
66 origin_y += 0.5 * delta_y;
70 {
"origin_x", origin_x}, {
"origin_y", origin_y},
71 {
"delta_x", delta_x}, {
"delta_y", delta_y},
72 {
"nx",
nx}, {
"ny",
ny}};
79 atoms.begin(), atoms.end(),
80 [](
auto &a,
auto &b) {
return a[
"z"] > b[
"z"]; });
87 const auto reciprocal_nx = 1.0 / double(
nx);
88 const auto reciprocal_ny = 1.0 / double(
ny);
89 const auto reciprocal_delta_x = 1.0 / delta_x;
90 const auto reciprocal_delta_y = 1.0 / delta_y;
92 auto n_atoms = atoms.size();
94 for (
int i = 0; i != n_atoms; ++i)
98 auto atom_x = atom[
"x"].get<
double>() - origin_x;
99 auto atom_y = atom[
"y"].get<
double>() - origin_y;
100 auto atom_z = atom[
"z"].get<
double>() -
offset;
102 auto radius = atom[
"radius"].get<
double>();
103 auto radius2 = radius*radius;
105 auto grid_index_min_x = ceil((atom_x-radius)*reciprocal_delta_x);
106 auto grid_index_min_y = ceil((atom_y-radius)*reciprocal_delta_y);
107 auto grid_index_max_x = ceil((atom_x+radius)*reciprocal_delta_x);
108 auto grid_index_max_y = ceil((atom_y+radius)*reciprocal_delta_y);
110 for (
int ix = grid_index_min_x; ix != grid_index_max_x; ++ix)
112 for (
int iy = grid_index_min_y; iy != grid_index_max_y; ++iy)
114 auto grid_x = ix*delta_x;
115 auto grid_y = iy*delta_y;
117 auto dx = atom_x - grid_x;
118 auto dy = atom_y - grid_y;
119 auto dr2 = dx*dx + dy*dy;
121 if (radius2 < dr2)
continue;
123 auto ix_in_box = ix - floor(ix*reciprocal_nx)*
nx;
124 auto iy_in_box = iy - floor(iy*reciprocal_ny)*
ny;
126 auto dz2 = radius2 - dr2;
128 auto d = atom_z - profile_tmp(ix_in_box, iy_in_box);
130 if (d < 0.0 && dz2 < d*d)
continue;
132 profile_tmp(ix_in_box, iy_in_box) = atom_z + sqrt(dz2);
Vec< ShPtr< Generator > > generators
ShPtr< Element > ElPtr
An alias for a shared pointer of Element class.
virtual void run_impl(const int index) override
Implementation of analysis using an element of generators.
const Vec< ArrayXXd > & get_profiles()
Get a sequence of two-dimensional profile of film thickness as list of two-dimensional arrays...
void set_offset(double offset_)
Specify the offset for thickness (height).
const Vec< Json > & get_conditions()
Get computation conditions (origin of computed area, grid width and the number of grads) used by this...
ProThicknessProfile(const ElPtr &atoms, const ElPtr &box)
Constructor of ProThicknessProfile class for a snapshot of simulation.
This file has a definition of ProThicknessProfile class, which is a subclass of Processor class...
std::vector< T > Vec
Vec is an alias for vector (same as list in Python).
void register_generator(const ShPtr< GEN > &gen)
void shift_half_delta(bool shift_half_=true)
Increment coordinates of the grid points by half the grid width. By default, grids in the x direction...
virtual void prepare() override
Resize conditions and profiles.
GenDict is a dictionary (or map) of Generator objects.
void set_grid(int nx_, int ny_)
Specify the number of grids in the x and y directions.
std::shared_ptr< T > ShPtr
ShPtr is an alias for shared pointer.
void register_generators(const Vec< ShPtr< GEN >> &gens)