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
Continuously Varying Material Tracking Method (CVMT) Implementation #1358
base: develop
Are you sure you want to change the base?
Conversation
Just wondering, how does this method generally perform compared to delta tracking? |
|
|
Interesting, thanks for the replies guys. Has anyone tried making this hybrid with delta tracking, kind of like how Serpent does hybrid delta tracking and ray tracing? |
As I know, none of us is working on the delta-tracking or hybrid with delta-tracking currently. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the PR @rockfool. This branch looks like it needs considerable clean-up before it would be ready for review. Please have a look at our C++ style guide and try to conform to it. I also do not see any tests or documentation which will be needed as well. Once this has been cleaned up and tests/docs added, ping me for a review again. Thanks!
src/particle.cpp
Outdated
d_collision = -std::log(prn()) / macro_xs_.total; | ||
|
||
// cvmt: continuous varying materials tracking | ||
if(model::materials[material_]->continuous_num_density_) d_collision = sampling_cvmt(this, boundary.distance); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Be cognizant of line length, try to keep lines under 80 or 90 characters wide
src/particle.cpp
Outdated
Particle::copy_data(LocalCoord &to, LocalCoord from){ | ||
to.r = from.r ; | ||
to.u = from.u ; | ||
to.cell = from.cell ; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't use extraneous whitespace between RHS and ;
src/particle.cpp
Outdated
this -> coord_[this -> n_coord_-1].u[1-1], | ||
this -> coord_[this -> n_coord_-1].u[2-1], | ||
this -> coord_[this -> n_coord_-1].u[3-1], | ||
this -> E_, ds); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All this debugging stuff should be removed
src/particle.cpp
Outdated
this -> coord_[this -> n_coord_-1].r[1-1], | ||
this -> coord_[this -> n_coord_-1].r[2-1], | ||
this -> coord_[this -> n_coord_-1].r[3-1], | ||
new_temp, xs_t[i-1]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Debugging stuff should be removed
src/particle.cpp
Outdated
printf("delta_tau_hat = %15.7f", delta_tau_hat); | ||
printf("index = %15d", index); | ||
printf("ds*(index-1) = %15.7f", ds * (index-1)); | ||
printf("ds*(index) = %15.7f", ds * (index)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove all these printfs
Thanks for your comments. I am going to remove those stuff that does not conform to C++ style, and try to prepare a testing case and the documentation in docs/neutron_physics.rst. |
Hi @rockfool. Just wanted to check in regarding this PR. If you'd like me to review this one again, please update it by merging the develop branch in order to resolve the existing merge conflicts. |
OK. I will try to reovle this conflict ASAP. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@rockfool This pull request still needs a bit of work. A few general comments that apply throughout:
- In many cases, you are declaring variables before you have a value to define them. This is a common source of uninitialized value bugs. Please move the variable declarations to the point of definition as well.
- There are many places throughout your code that don't match our style guide. Rather than fixing one-by-one, what I'd suggest you do is to use clang-format along with the
.clang-format
file in the root directory of the repo to automatically apply formatting. That will save both of us the headache of addressing the minor style issues - It looks like the only polynomials that are supported are Zernike polynomials. I think to be considered a general capability, we would want to support the ability to set arbitrary polynomials in x, y, and z.
- I don't see any support for this feature on the Python side; that will need to be added in order to be given full consideration for merging.
double radius_; //! the radius of the expansion | ||
std::vector<double> coeffs_; //! coefficients for poly evaluation | ||
std::vector<double> poly_norm_; //! polynomial norm available to property for efficiency | ||
public: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
NL.16: Put public members before private
poly_norm_.resize(n_coeffs_); | ||
} | ||
|
||
PolyProperty::~PolyProperty() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This destructor is not needed -- when the object is destructed, the memory from the vectors will be removed
return property; | ||
} | ||
|
||
PolyProperty::PolyProperty(int n_size) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would have the constructor be:
PolyProperty::PolyProperty(const std::string& type, const std::vector<double>& coeffs)
and then have all the members (n_coeffs_
, coeffs_
, order_
, type_
) be set directly in the constructor rather than have that logic spill into the Material constructor.
{ | ||
int c_index; | ||
double rho, poly_val, property; | ||
rho = std::sqrt(r.x * r.x + r.y * r.y) / coeffs_[0]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't declare a variable until you have a suitable value for it:
rho = std::sqrt(r.x * r.x + r.y * r.y) / coeffs_[0]; | |
double rho = std::sqrt(r.x * r.x + r.y * r.y) / coeffs_[0]; |
int c_index; | ||
double rho, poly_val, property; | ||
rho = std::sqrt(r.x * r.x + r.y * r.y) / coeffs_[0]; | ||
c_index = 2; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
c_index = 2; | |
int c_index = 2; |
double ds, new_temp; | ||
LocalCoord coord; | ||
|
||
copy_data(coord, this->coord_[this->n_coord_ - 1]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pretty sure the following will work:
LocalCoord coord = this->coord_[this->n_coord_ - 1];
and then remove the copy_data
method
} | ||
|
||
void | ||
Particle::estimate_flight_distance(std::vector<double> xs_t, double distance, double tau_hat, double& s) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks like it doesn't need to be a method of Particle
and can be a plain function instead. Also, why not just return a double
instead of having that last parameter?
} | ||
|
||
void | ||
Particle::get_quadratic_root(double a, double b, double c, double lower_b, double upper_b, double& root) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks like it doesn't need to be a method of Particle
and can be a plain function instead
} | ||
|
||
void | ||
Particle::get_cubic_root(double a, double b, double c, double d, \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks like it doesn't need to be a method of Particle
and can be a plain function instead
void simpsons_path_integration(double& optical_depth, double distance, std::vector<double> &xs_t, bool dbg_file, int it_num); | ||
void estimate_flight_distance(std::vector<double> xs_t, double distance, double tau_hat, double& s); | ||
void get_quadratic_root(double a, double b, double c, double lower_b, double upper_b, double& root); | ||
void get_cubic_root(double a, double b, double c, double d, double lower_b, double upper_b, double& root); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For all these functions/methods, you need to add Doxygen comments above describing what the parameters are
This PR is to add CVMT method in the particle tracking. It allows the nuclides number densities in Material class be expressed by the functional expansion. However, the functional expansion tallied nuclides number densities is not determined. Any comment will be appreciated. I am also preparing the testing cases for this implementaion.