-
Notifications
You must be signed in to change notification settings - Fork 22
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
openPMD Beam Input via Source
Element
#820
base: development
Are you sure you want to change the base?
Conversation
/** Unclutter a real_names to openPMD record | ||
* | ||
* TODO: move to ABLASTR | ||
* | ||
* @param fullName name as in real_names variable | ||
* @return pair of openPMD record and component name | ||
*/ | ||
inline std::pair< std::string, std::string > | ||
name2openPMD ( const std::string& fullName ) | ||
{ | ||
std::string record_name = fullName; | ||
std::string component_name = io::RecordComponent::SCALAR; | ||
|
||
// we use "_" as separator in names to group vector records | ||
std::size_t const startComp = fullName.find_last_of('_'); | ||
if( startComp != std::string::npos ) { // non-scalar | ||
record_name = fullName.substr(0, startComp); | ||
component_name = fullName.substr(startComp + 1u); | ||
} | ||
return make_pair(record_name, component_name); | ||
} | ||
|
||
// TODO: move to ablastr | ||
io::RecordComponent get_component_record ( | ||
io::ParticleSpecies & species, | ||
std::string comp_name | ||
) { | ||
// handle scalar and non-scalar records by name | ||
const auto [record_name, component_name] = name2openPMD(std::move(comp_name)); | ||
return species[record_name][component_name]; | ||
} |
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.
Cleanup: deduplicate from BeamMonitor
implementation.
ref.set_charge_qe(-1.0).set_mass_MeV(0.510998950).set_kin_energy_MeV(kin_energy_MeV) | ||
|
||
# load particle bunch from file | ||
push(pc, elements.Source("../FODO_channel/diags/openPMD/monitor.h5")) |
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.
Depending on the use case, i.e., checkpoint-restart, it can be useful here to also (re-)set the s
position of the reference particle -- and the whole reference particle per se.
We could add a runtime option for this.
For Sirepo, we only need to load an initial distribution for now.
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.
By this, I think you mean--to read in the reference particle data (at the specified s location), and to use this to initialize the reference particle during the restart? If so, I agree that this feature will be needed for checkpoint-restart capability.
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, in that case it would replace the lines just before this line in the script. I think that would make a good runtime option.
############################################################################### | ||
lattice.elements = monitor drift1 quad1 drift2 quad2 drift3 | ||
lattice.nslice = 5 | ||
lattice.periods = 101 # FODO channel of 101 periods |
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.
Unlike run_fodo.py
, I don't see user input for a restart in the app input file. Is the intention to add the capability of restart via the app input also?
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.
Ah yes, I have not developed this yet. I meant to remove this file from the commit because I only did Python so far.
.def("redistribute", | ||
&ImpactXParticleContainer::Redistribute, | ||
"Redistribute particles in the current mesh in x, y, z" | ||
) |
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 function no longer needed? Not sure why this is deleted here--how it is related to this PR.
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.
Correct. This is actually already exposed in pyAMReX. The binding here overwrote it and, problematically, did not define the proper default arguments that go into Redistribute(...)
. Just removing it solves this and removes the sloppy duplication that I did by accident.
Co-authored-by: Chad Mitchell <[email protected]>
Add a new element
Source
that reads openPMD files from our beam monitors. Add an example in Python. Close #97This can also be used to restart a simulation that was checkpointed at a beam monitor.
Follow-Up Ideas
This is designed intentionally as a new element. In the future, we probably restructure our initial distribution logic to also go into this element, so that "from file" is just one of its options.
For other projects, we will implement t-to-s transforms (for WarpX) and other options, as documented in inline TODOs.
Not needed for Sirepo, but we will also add an option to use this from inputs files.