Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support 2D projections #6

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 21 additions & 1 deletion parametric_plasma_source/source_sampling.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ const double shafranov_shift = 0.0; //metres
const std::string name = "parametric_plasma_source";
const int number_of_bins = 100;
const int plasma_type = 1; // 1 is default; //0 = L mode anything else H/A mode
const std::string basis = "xyz"; // xyz for 3D, ry or rz for 2D
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we tie this to an enum?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense. Linked to an enum now. The enum will need a bit of a tweak when serialising but not major.




Expand Down Expand Up @@ -70,9 +71,28 @@ extern "C" openmc::Particle::Bank sample_source(uint64_t* seed) {
source.SampleSource(randoms,particle.r.x,particle.r.y,particle.r.z,
u,v,w,E);

// Convert m to cm
particle.r.x *= 100.;
particle.r.y *= 100.;
particle.r.z *= 100.;
particle.r.z *= 100.;

if(basis == "xyz") {
// Use values as-is
}
else if(basis == "ry") {
particle.r.x = std::sqrt(std::pow(particle.r.x, 2) + std::pow(particle.r.y, 2));
particle.r.y = particle.r.z;
particle.r.z = 0.;
}
else if(basis == "rz") {
particle.r.x = std::sqrt(std::pow(particle.r.x, 2) + std::pow(particle.r.y, 2));
particle.r.y = 0.;
particle.r.z = particle.r.z;
}
else {
throw std::runtime_error("Parametric plasma source: incorrect basis provided, "
"please use xyz, ry, or rz.");
}

// particle.E = 14.08e6;
particle.E = E*1e6; // convert from MeV -> eV
Expand Down