Retile mesh functionality #189
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
Added functionality which allows the user to change the mesh extents of space charge elements during runtime, without the need of removing/recreating SC elements and rebuilding tracker. Grid count remains unchanged. Compared to re-using
replace_spacecharge_with_PIC(), it removes the need to rebuild the line each time.Right now the user themselves will need to implement in their own script when to retile the mesh, and to what new extents etc. For example, in the case of using space charge elements originally created with
replace_spacecharge_with_PIC(), the user themselves will need to make sure the relative mesh extents for the different elements in the line are kept.This functionality has been implemented for
SpaceCharge3Dobjects with eitherFFTSolver3DorFFTSolver2p5Das solver. A new testfile (test_change_pic_mesh.py) has been added to test the functionality.Usage:
On a
SpaceCharge3Dobject, call either the functionset_xy_mesh()orset_xyz_mesh()with desired new ranges, and optionally if storedrho,phianddphi_*should be set to zero after the retile. Doing this will call eitherretile_xy()orretile_xyz()with the given arguments. The retile functions will change necessary values for the fieldmap, and thereafter callrefresh_geometry()on the fieldmap's solver.refresh_geometry(), which takes the x/y/z-grids as input, will in turn rebuild the Greens function for the new cell sizes.If
zero_fields=Truefor eitherretile- orset_*_meshfunctions are used, this avoids using fields calculated for an old mesh when e.g.update_on_track=Falseduring tracking. When e.g.update_on_track=True, this option does not matter as fields are overwritten anyways.It is possible to directly call the
retilefunctions and/orrefresh_geometry()given one has access to a fieldmap and/or solver, if one does not wish to modify higher levels (not recommended outside of testing).Checklist
Mandatory:
Optional: