Skip to content

Commit

Permalink
Implement faraday source for single particle process
Browse files Browse the repository at this point in the history
  • Loading branch information
tobre1 committed May 15, 2024
1 parent 7e9fecb commit 1554a7e
Show file tree
Hide file tree
Showing 5 changed files with 54 additions and 38 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ CPMAddPackage(

CPMFindPackage(
NAME ViennaRay
VERSION 2.1.0
VERSION 2.1.2
GIT_REPOSITORY "https://github.com/ViennaTools/ViennaRay"
EXCLUDE_FROM_ALL ${VIENNAPS_BUILD_PYTHON})

Expand Down
7 changes: 3 additions & 4 deletions app/application.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -304,8 +304,7 @@ template <int D> class Application {
break;

case GeometryType::PLANE:
std::cout << "Plane"
<< "\n\tzPos: " << params->maskZPos << "\n\n";
std::cout << "Plane" << "\n\tzPos: " << params->maskZPos << "\n\n";
if (geometry->getLevelSets()->back()) {
std::cout << "\tAdding plane to current geometry...\n\n";
psMakePlane<NumericType, D>(geometry, params->maskZPos,
Expand Down Expand Up @@ -340,8 +339,8 @@ template <int D> class Application {
<< "\n\tzPos: " << params->maskZPos
<< "\n\tinvert: " << boolString(params->maskInvert)
<< "\n\txPadding: " << params->xPadding
<< "\n\tyPadding: " << params->yPadding << "\n\tPoint order: "
<< "\n\n";
<< "\n\tyPadding: " << params->yPadding
<< "\n\tPoint order: " << "\n\n";

if constexpr (D == 3) {
typename lsDomain<NumericType, D>::BoundaryType boundaryCons[D];
Expand Down
4 changes: 2 additions & 2 deletions examples/KDTreeBenchmark/KDTreeBenchmark.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,8 @@ int main(int argc, char *argv[]) {
std::cout << "Finding Nearest Neighbors...\n";
startTime = getTime();
for (unsigned i = 0; i < repetitions; ++i) {
for (const auto &pt : testPoints)
[[maybe_unused]] auto result = tree->findNearest(pt);
for (const auto &pt : testPoints) [[maybe_unused]]
auto result = tree->findNearest(pt);
}
endTime = getTime();

Expand Down
10 changes: 5 additions & 5 deletions examples/faradayCageEtching/config.txt
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
gridDelta = 0.5
xExtent = 35.0
yExtent = 25.0
yExtent = 35.0

finWidth = 8.0
finHeight = 3.0
taperAngle = 0.0
boxWidth = 10.0
boxHeight = 5.0

sourceExtend = 2.
processTime = 10.0
raysPerPoint = 1000

angle = 45
angle = 50
69 changes: 43 additions & 26 deletions examples/faradayCageEtching/faradayCageEtching.cpp
Original file line number Diff line number Diff line change
@@ -1,52 +1,57 @@
#include <geometries/psMakeFin.hpp>
#include <geometries/psMakePlane.hpp>

#include <models/psDirectionalEtching.hpp>
#include <models/psIonBeamEtching.hpp>
#include <models/psSingleParticleProcess.hpp>
#include <psProcess.hpp>

template <typename NumericType, int D>
class FaradayCageSource : public raySource<NumericType> {
public:
FaradayCageSource(const NumericType xExtent, const NumericType yExtent,
const NumericType zPos, const NumericType gridDelta,
const NumericType angle)
: minPoint_{-xExtent / 2., -yExtent / 2.},
maxPoint_{xExtent / 2., yExtent / 2.}, zPos_(zPos),
gridDelta_(gridDelta), angle_(angle * M_PI / 180.) {}
const NumericType angle, const NumericType extendFac = 1.)
: minPoint_{-xExtent / 2., -yExtent / 2.}, extent_{xExtent, yExtent},
zPos_(zPos), gridDelta_(gridDelta), angle_(angle * M_PI / 180.),
extendFac_(extendFac) {}

rayPair<rayTriple<NumericType>>
getOriginAndDirection(const size_t idx, rayRNG &RngState) const {
std::uniform_real_distribution<NumericType> dist(0., 1.);

rayTriple<NumericType> origin;
origin[0] = minPoint_[0] + (maxPoint_[0] - minPoint_[0]) * dist(RngState);
origin[1] = minPoint_[1] + (maxPoint_[1] - minPoint_[1]) * dist(RngState);
origin[0] = extendFac_ * minPoint_[0] +
(extent_[0] * extendFac_ * 2. - extent_[0]) * dist(RngState);
origin[1] = extendFac_ * minPoint_[1] +
(extent_[1] * extendFac_ * 2. - extent_[1]) * dist(RngState);
origin[2] = zPos_;

rayTriple<NumericType> direction;
if (minPoint_[0] < 0) {
direction[0] = -cos(angle_);
if (origin[0] < 0) {
direction[0] = cos(angle_);
direction[1] = 0.;
direction[2] = sin(angle_);
direction[2] = -sin(angle_);
} else {
direction[0] = cos(angle_);
direction[0] = -cos(angle_);
direction[1] = 0.;
direction[2] = sin(angle_);
direction[2] = -sin(angle_);
}
rayInternal::Normalize(direction);

return {origin, direction};
}

size_t getNumPoints() const {
return (maxPoint_[0] - minPoint_[0]) * (maxPoint_[1] - minPoint_[1]) /
(gridDelta_ * gridDelta_);
return extent_[0] * extent_[1] / (gridDelta_ * gridDelta_);
}

private:
std::array<NumericType, 2> const minPoint_;
std::array<NumericType, 2> const maxPoint_;
std::array<NumericType, 2> const extent_;
NumericType const zPos_;
NumericType const gridDelta_;
NumericType const angle_;
NumericType const extendFac_;
};

int main(int argc, char *argv[]) {
Expand All @@ -61,18 +66,30 @@ int main(int argc, char *argv[]) {
if (argc > 1) {
params.readConfigFile(argv[1]);
} else {
std::cout << "Usage: " << argv[0] << " <config file>" << std::endl;
std::cout << "Usage: " << argv[0] << " <parameter file>" << std::endl;
return 1;
}

// geometry setup
auto geometry = psSmartPointer<psDomain<NumericType, D>>::New();
psMakeFin<NumericType, D>(
geometry, params.get("gridDelta"), params.get("xExtent"),
params.get("yExtent"), params.get("finWidth"), params.get("finHeight"),
params.get("taperAngle"), 0. /* base height */,
false /* periodic boundary */, true /*create mask*/, psMaterial::Si)
psMakePlane<NumericType, D>(geometry, params.get("gridDelta"),
params.get("xExtent"), params.get("yExtent"),
0. /* base height */,
true /* periodic boundary */, psMaterial::Si)
.apply();
{
auto box = psSmartPointer<lsDomain<NumericType, D>>::New(
geometry->getLevelSets()->back());
NumericType minPoint[D] = {-params.get("boxWidth") / 2.,
-params.get("boxWidth") / 2., 0.};
NumericType maxPoint[D] = {params.get("boxWidth") / 2.,
params.get("boxWidth") / 2.,
params.get("boxHeight")};
lsMakeGeometry<NumericType, D>(
box, lsSmartPointer<lsBox<NumericType, D>>::New(minPoint, maxPoint))
.apply();
geometry->insertNextLevelSetAsMaterial(box, psMaterial::Mask);
}

{
std::array<NumericType, 3> direction = {0., 0., -1.};
Expand All @@ -82,17 +99,17 @@ int main(int argc, char *argv[]) {
}

// use pre-defined IBE etching model
auto model = psSmartPointer<psIonBeamEtching<NumericType, D>>::New(
std::vector<psMaterial>{psMaterial::Mask});
auto &modelParams = model->getParameters();
auto model = psSmartPointer<psSingleParticleProcess<NumericType, D>>::New(
-1.0, 1.0, 1.0, std::vector<psMaterial>{psMaterial::Mask});
// auto &modelParams = model->getParameters();

// faraday cage source setup
auto source = psSmartPointer<FaradayCageSource<NumericType, D>>::New(
params.get("xExtent"), params.get("yExtent"),
params.get("finHeight") + params.get("gridDelta") / 2.,
params.get("boxHeight") + params.get("gridDelta") / 2.,
params.get("gridDelta"), params.get("angle"));
model->setSource(source);
modelParams.tiltAngle = params.get("angle");
// modelParams.tiltAngle = params.get("angle");

// process setup
psProcess<NumericType, D> process;
Expand Down

0 comments on commit 1554a7e

Please sign in to comment.