-
Notifications
You must be signed in to change notification settings - Fork 44
Restructured backend for SolTrace #63
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
Conversation
…ses; start implementing APIs
… CMake to use cpp 17.
…n on the powertower sample
…o see how it runs
…n result storage; move ray data to shared pointer
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.
Pull Request Overview
Copilot reviewed 124 out of 147 changed files in this pull request and generated 4 comments.
Comments suppressed due to low confidence (2)
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
| #include <fstream> | ||
| #include <iostream> | ||
| #include <string> | ||
| #include <sstream> | ||
| #include <vector> | ||
|
|
||
| using namespace std; |
Copilot
AI
Oct 1, 2025
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.
Avoid using 'using namespace std;' in header files or at global scope. It pollutes the global namespace and can cause naming conflicts. Use specific using declarations or fully qualified names instead.
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.
The using statement is in a .cpp file. Probably not something that needs to be addressed.
| MTRand myrng(1); | ||
| double random_number = myrng.rand(); | ||
|
|
||
| EXPECT_NEAR(random_number, 0.13387664401253274, 0.0000001); | ||
| EXPECT_NEAR(random_number, 0.13387664401253274, 1e-7); |
Copilot
AI
Oct 1, 2025
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.
Consider using a named constant for the expected value and tolerance to improve readability and maintainability. Magic numbers make the test harder to understand and modify.
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 is a test for the legacy code and will likely be deprecated at some point.
| goto Label_9; | ||
| } | ||
| else | ||
| { | ||
| Euler[0] = PI / 2.0; | ||
| goto Label_8; | ||
| } | ||
| } | ||
|
|
||
| Euler[0] = atan2(CosIn[0], CosIn[2]); | ||
| Label_8: | ||
| Euler[1] = atan2(CosIn[1], sqrt(CosIn[0] * CosIn[0] + CosIn[2] * CosIn[2])); | ||
| Label_9: |
Copilot
AI
Oct 1, 2025
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.
Use of goto statements makes code harder to read and maintain. Consider refactoring this logic using structured control flow (if/else, functions, or early returns) instead.
| goto Label_9; | |
| } | |
| else | |
| { | |
| Euler[0] = PI / 2.0; | |
| goto Label_8; | |
| } | |
| } | |
| Euler[0] = atan2(CosIn[0], CosIn[2]); | |
| Label_8: | |
| Euler[1] = atan2(CosIn[1], sqrt(CosIn[0] * CosIn[0] + CosIn[2] * CosIn[2])); | |
| Label_9: | |
| } | |
| else | |
| { | |
| Euler[0] = PI / 2.0; | |
| Euler[1] = atan2(CosIn[1], sqrt(CosIn[0] * CosIn[0] + CosIn[2] * CosIn[2])); | |
| } | |
| } | |
| else | |
| { | |
| Euler[0] = atan2(CosIn[0], CosIn[2]); | |
| Euler[1] = atan2(CosIn[1], sqrt(CosIn[0] * CosIn[0] + CosIn[2] * CosIn[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.
Noted in #71 and to be addressed in a future PR.
| NIter = 10; | ||
| Epsilon = 0.000005; |
Copilot
AI
Oct 1, 2025
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.
These appear to be magic numbers that should be defined as named constants at the top of the file or as class members to improve maintainability and make their purpose clear.
Convert parabola args to from cx to fx.
taylorbrown75
left a comment
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.
Looks good. Legacy SolTrace GUI and coretrace can be built by setting CMakelist variables to ON. Legacy sample files run, tests pass on my machine.
.github/workflows/CI.yml
Outdated
| on: | ||
| push: | ||
| branches: [ develop, trace_refactor ] | ||
| branches: [ develop, trace_refactor, jm-dev-tmb ] |
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 trace_refactor on both push and PRs
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.
Returned to just develop
Fix focal length check bug.
| return; | ||
| } | ||
|
|
||
| void Heliostat::enforce_user_fields_set() const |
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.
We are missing some of the class user set fields here, e.g., gap_x.
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 see your checking them as they are set.
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.
It should still get checked by the enforce_user_fields_set function. I will add it.
| { | ||
| if (this->initialized) | ||
| { | ||
| CompositeElement::enforce_user_fields_set(); |
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.
As written, I believe this will always be skipped. The template only calls this function if initialized is False.
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.
The enforce_user_fields_set function gets called when the element is added to a SimulationData object as well, at which point it is initialized and this will get called.
| elem->set_aperture(ap); | ||
|
|
||
| // // TODO: Is this the correct thing to do here? | ||
| // vector_add(1.0, this->focal_point, -1.0, origin, aim); |
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.
What is the focal_point? Should this and the other code referring to it be removed?
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.
Probably something from when I was trying to implement it. I will remove it.
| if (this->focal_length_x <= 0.0 && this->focal_length_y <= 0.0) | ||
| { | ||
| surf = make_surface<Flat>(); | ||
| // Vector3d khat(0.0, 0.0, 1.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.
remove?
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.
Indeed.
| 0.0); | ||
|
|
||
| elem->set_front_optical_properties(this->optics_mirror); | ||
| elem->set_back_optical_properties(this->optics_mirror); |
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.
We should probably make the back surface properties different. Either fixed to some default "absorber" or provide access to customize.
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 will add a TODO about this.
It was while doing these templates that I realized we should rework the optical properties to have be a single object with a front and back so we can do error checking make it a bit easier to create elements (less verbose).
qualand
left a comment
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.
Great start. I think we have a lot of loose ends to build out in the coming months.
|
|
||
| sun_position_vector_degrees(this->sun_position, azimuth, elevation); | ||
| Vector3d target_dir; | ||
| vector_add(1.0, this->target_pos, |
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.
Should we add a check target_set before these calculations?
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 gets checked by the enforce_user_fields_set function which is called at the top of the initialize function.
| throw std::invalid_argument(ss.str()); | ||
| } | ||
|
|
||
| this->coordinates_initialized = false; |
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.
Should we add a check on this->initialized? that either calls create_geometry or throws an error.
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.
Yes. Added a check and an error throw.
| return; | ||
| } | ||
|
|
||
| void Heliostat::enforce_user_fields_set() const |
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 see your checking them as they are set.
| REFRACTION | ||
| }; | ||
|
|
||
| // enum DistributionType |
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
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.
Done.
| optics_front(), | ||
| optics_back() | ||
| { | ||
| // TODO: Do we want a default aperture and surface? What about default |
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 set the default to a flat rectangle (1x1) set to a perfect absorber.
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.
Aperture and surface have checks to make sure they get set. I updated the optics to default to ideal absorber.
|
|
||
| namespace SolTrace::Data { | ||
|
|
||
| StageElement::StageElement(int_fast64_t stage) : CompositeElement() |
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.
Is this how you envision Stages being handled? Will this implementation run into issues when the added element is a compositeElement, e.g., a CST template.
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.
Adding a composite element to a stage is allowed so you can add a CST template to a stage. But this should work to handle stages since they are largely a way for users to define a local coordinate system.
Work in progress: