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

Feature/dlw components 3 #49

Merged
merged 8 commits into from
Mar 24, 2023
Merged

Feature/dlw components 3 #49

merged 8 commits into from
Mar 24, 2023

Conversation

whaeck
Copy link
Member

@whaeck whaeck commented Nov 18, 2021

Three more energy distribution options:

  • discrete photon
  • equiprobable outgoing energy bins
  • general evaporation spectrum

@whaeck whaeck changed the base branch from develop to feature/dosimetry February 22, 2023 23:31
Base automatically changed from feature/dosimetry to develop March 23, 2023 17:36
Copy link

@cjosey cjosey left a comment

Choose a reason for hiding this comment

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

Only thing blocking approval is the incorrect doxygen comment. Rest is just questions, design stuff, and me probably getting confused by pointers.


"LP",
&Block::LP,
"The primary flag value (0, 1 or 2)"
Copy link

Choose a reason for hiding this comment

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

[design question, future]
Should these return enums or similar instead?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, we probably should do that. I'll make that into an issue.

)
.def_property_readonly(

"number_bins",
Copy link

Choose a reason for hiding this comment

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

[aside]
I almost got caught out by number_bins not being NET and was going to comment their documentation is different.

class Test_ACEtk_GeneralEvaporationSpectrum( unittest.TestCase ) :
"""Unit test for the GeneralEvaporationSpectrum class."""

chunk = [ 0,
Copy link

Choose a reason for hiding this comment

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

[clarification]
I'm a bit confused on the value of NR. In the ACE format document, it indicates that if NR = 0, then you use linear-linear interpolation.

Is this related to the multi-law stuff and thus I won't see any tests with a non-zero value until then? It is tricky to figure out what this does from the format manual.

Copy link
Member Author

Choose a reason for hiding this comment

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

It seems to be an option in the ACE format but I've never seen anything that uses NR != 0. We can talk about this in more detail when we go over these things after my updates following the review.

{ return value.incidentEnergy(); };

std::sort( distributions.begin(), distributions.end(),
[=] ( const auto& left, const auto& right )
Copy link

Choose a reason for hiding this comment

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

I don't think the [=] is doing anything as all the variables I see used are passed as arguments, but if it were, would it be better to [&]?

Copy link
Member Author

Choose a reason for hiding this comment

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

The incidentEnergy lambda should get captured here.

xss[index] = std::visit( [] ( const auto& value )
{ return value.incidentEnergy(); },
distribution );
xss[index] = std::visit( incidentEnergy, distribution );

// set the locator
Copy link

Choose a reason for hiding this comment

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

[non-PR aside]
Should this comment note that it is LOCC? I was baffled by it setting a negative value until I tracked that down.

Copy link
Member Author

Choose a reason for hiding this comment

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

I updated the comment to be more clear on what is happening

/**
* @brief Return the primary flag value (0, 1 or 2)
*/
unsigned int primaryPhotonFlag() const { return this->LP(); }
Copy link

Choose a reason for hiding this comment

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

[question]
LP=2 has different kinematics than LP=0 or 1 (and takes the excess kinetic energy from an incident particle, making it "primary"). What distinguishes LP=0 from LP=1?

// reserve size in the vector
std::size_t nr = boundaries.size();
std::size_t ne = distributions.size();
std::vector< double > xss( 2 + ne ); // NE, list of energies, NET
Copy link

Choose a reason for hiding this comment

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

[comment]
This way of constructing XSS appears to be 100% correct. However, I had to spend more time than I'd like proving it to myself due to the nonlinearity going on (allocate, prepend, set values, append).

int numberBins() const { return this->length() - 1; }

/**
* @brief Return the cosine values
Copy link

Choose a reason for hiding this comment

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

Documentation is incorrect.

Copy link
Member Author

Choose a reason for hiding this comment

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

I corrected this. I also checked the python side where it seems to be correct.

GeneralEvaporationSpectrum& operator=( const GeneralEvaporationSpectrum& base ) {

new (this) GeneralEvaporationSpectrum( base );
return *this;
Copy link

@cjosey cjosey Mar 23, 2023

Choose a reason for hiding this comment

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

[question]
How do you prevent memory leaks caused by repeatedly doing:

GeneralEvaporationSpectrum& x = y;

and letting x go out of scope - say, in a loop?

[Edit] did some research, did not know about placement-new. In discussions, people note that since new is not exception-safe, this can create malformed objects on exception. Also, it may not be well-defined if you do x = x. Which is odd but possible.

Copy link
Member Author

Choose a reason for hiding this comment

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

I probably should look into this some more.

@whaeck whaeck merged commit 1c09ea7 into develop Mar 24, 2023
@whaeck whaeck deleted the feature/dlw-components-3 branch March 24, 2023 00:05
whaeck added a commit that referenced this pull request Jun 26, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants