Skip to content

Dump sources#46

Merged
alexvalentine94 merged 14 commits intodevelopingfrom
dump_sources
Mar 21, 2025
Merged

Dump sources#46
alexvalentine94 merged 14 commits intodevelopingfrom
dump_sources

Conversation

@digiacomo4
Copy link
Copy Markdown
Contributor

Added arguments to "dump_source" to automatically generate the sdef card for an mcnp simulation. The main changes can be found on the added file "psource.py" and for the time being it is only available for point/multiple points sources.

Major changes:
Through actigamma it computes the gamma lines for each point and it automatically sets the discrete energy bin (SI3 L..) and relative frequency for each bin (SP3 ..), relative strengths of sources (SP1 ..), enegy distributions (DS2 ...) and coordinates of the point/points (listed in the "SI1 L" line). Moreover the dose factor conversion coefficient are also provided along with the multiplier (FM4) (total gammas emitted).

Different functions have been added to format the final "source.sdef" in order to respect the character limit per line in MCNP, and several test have been added to check each new implemented function.

Minor changes:
Another irradiation time of 1 year has been added for numerical computation comparison with simpler case scenario.
Different libraries changed the order in which they were listed due to Ruff.

@digiacomo4 digiacomo4 requested review from alexvalentine94 and dodu94 and removed request for alexvalentine94 and dodu94 March 17, 2025 17:18
Copy link
Copy Markdown
Member

@dodu94 dodu94 left a comment

Choose a reason for hiding this comment

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

Thanks @digiacomo4 for this, a few comments below

# Avoid division by zero
if distance == 0:
dose_array[i, j, k] = dose[0]
print("Dose at source point is:", dose[0])
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

print statement should be deleted

# distance = np.sqrt(
# (x_mid[i] - x1) ** 2 + (y_mid[j] - y1) ** 2 + (z_mid[k] - z1) ** 2
# )
# Avoid division by zero
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I think computing the values in the center of the voxel is more correct than computing it in one of the vertex and then shift it in the center

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

If changing to middle point than the point value a 0 distance should be still divided by a distance value and not just be equal to "dose[0]" has it is now. I would suggest leave it like this; if an .stl file is not provided, I do not think 25 cm shift impact significantly, especially at several meters distances.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Implemented. Please note that the in case of distance==0 the dose value will be divided by 4*pi.

# print(
# f"Max dose value: {dose_array[indices]} at coordinates: ({x_max}, {y_max}, {z_max})"
# )
# Create the output directory if it doesn't exist
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This can probably be deleted and not just commented out

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This file should not be tracked, please delete and consider adding it to .gitignore

Copy link
Copy Markdown
Collaborator

@alexvalentine94 alexvalentine94 left a comment

Choose a reason for hiding this comment

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

Thanks Matteo for the nice addition. The only thing missing is documentation but this is on me to first set up so we can handle later.

"pandas",
"jsonargparse",
"scipy",
"actigamma",
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This is a good addition (for what is needed). I just note that as an action for the future that in the shielding module of the code the retrieval of gamma lines was done using the API for the IAEA NDS. Just for consistency, now we have this dependency, actigamma could also be used.

dose_factors_df,
)
dose_arrays.append(dose_array)
if args.dump_source:
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I think we could better name this... 'write_sdef' for example.


if args.dump_source:
global_source = GlobalPointSource(sources)
global_source.to_sdef(f"{run_dir}/source.sdef") # TODO
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

TODO statement?


# Add the optional "mcnp" argument
parser.add_argument(
"--dump_source",
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

above comment r.e. naming

gamma_per_second_line = (
f"FM4 {t_gamma:.2E} $ To be multiplied by 3.6E-09 to obtain Sv/hr\n"
)
conv_coeff_line = "DE4\n 0.01 0.015 0.02 0.03 0.04 0.05 0.06 0.07 0.08 0.10 0.15 0.20 0.3 0.4 0.5 0.6 0.8 1.0 2.0 4.0 6.0 8.0 10.0\nDF4\n 0.0485 0.1254 0.2050 0.2999 0.3381 0.3572 0.3780 0.4066 0.4399 0.5172 0.7523 1.0041 1.5083 1.9958\n 2.4657 2.9082 3.7269 4.4834 7.4896 12.0153 15.9873 19.9191 23.7600"
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

These vary depending on convention. If we are to keep them, we should add a reference e.g. ICRP-74 H*(10) on a comment card in the MCNP input.

Compute the inventory of unstable nuclides for the line source.
"""

pass
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Could we open issue for this?

Copy link
Copy Markdown
Member

@dodu94 dodu94 left a comment

Choose a reason for hiding this comment

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

Thanks Matteo, it was a long journey but I think you have done it

Copy link
Copy Markdown
Collaborator

@alexvalentine94 alexvalentine94 left a comment

Choose a reason for hiding this comment

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

Thanks Matteo for making the changes and the new feature!

@alexvalentine94 alexvalentine94 merged commit c24a5dc into developing Mar 21, 2025
4 checks passed
@alexvalentine94 alexvalentine94 deleted the dump_sources branch March 21, 2025 16:49
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.

3 participants