Closed cy1034429432 closed 10 months ago
Hi,
Could you share a bit more what you are trying to achieve ?
Regarding your questions:
Hi! Thank you for replying to my message. I am currently building a seamless model for a proton therapy facility, and we have successfully established it using BDSIM. However, due to particle tracking, BDSIM has a slow calculation speed. We would like to replace it with a faster code. Regarding question 1, we only control the energy and quality by controlling the thickness of the graphite block and distance of the energy slit in the vacuum (energy selection system), and then particles reach the treatment nozzle through the beamline. Can this process be fully modeled in Georges?
This was exactly our approach. We have a very detailed model with BDSIM and we used (and developed) Georges for faster tracking and optimisation of the beam line.
Yes, you can insert a "degrader" element for your graphite blocks, the energy will be reduced and the multiple coulomb scattering is modelled in some way. The slits will "kill" particles and you can have the rest of the magnetic elements.
Feel free to share more if you want some support (possibly by email through this paper https://www.sciencedirect.com/science/article/pii/S2352711023002753 )
Thank you for your answer. I have carefully read the literature you provided. If possible, we hope Georges can add features similar to the Enge function in the future. BDSIM has some inconveniences in importing dipole fields, and we hope to establish a more realistic physical model (considering fringe fields, over-talk effect, and particle-matter collision processes). Also, is it possible to provide a seamless example on the website that includes the energy degradation process and particle transport? Special thanks.
@chernals Hi, After trying to use Georges, there were a few questions that puzzled me:
Hello, thanks for all the comments. I opened some issues to treat each point separately.
However, this is not a huge amount of work to create a distribution given sigmaE.
I will try to resolve the issues this week. I will also provide an example that includes the energy degradation process and particle transport.
@rtesse Hi, Thank you for responding to my questions.
Hello, I created a new release for Georges (2024.1) which is also available on Pypi. I improved the documentation for the aperture and the parameters of (almost) each element. Regarding your issue with the HGAP, could you try your example in a fresh conda environment ?
@rtesse Hi. I followed your suggestion and downloaded the latest version of Georges in a new Conda environment, but there is still an issue with HGAP. I still had the relevant installation on another computer, and this issue also exists. Also, I have looked over the examples you gave about the energy degrader. I have a question. When the energy of particles changes after the energy degradation, there is a scaling option in BDSIM to adjust the magnets’ parameters downstream of the energy degrader, but it is not available in Georges. Shall we need to manually adjust the magnets’ parameters downstream of the energy degrader?
Hello, Ok this is strange as I am not able to reproduce the bug. Could you try this MWE and tell me if you still have the issue ? If not, could you post the code as I can debug it on my side ?
import georges
from georges import Element
from georges import ureg as _ureg
B3G2 = Element.SBend('A', L=1*_ureg.m,
HGAP=5*_ureg.cm,
E1=-0.4346,
E2=-0.2889)
Regarding the energy degradation, I have to check but if I remember correctly, you have to manually adapt the magnet's parameters.
@rtesse Hello, I have sent the simplified code to your email. Regarding the energy degradation, I can adjust the K value of the quadrupole based on the momentum ratio, but the downstream dipole cannot adjust the B value according to the currently provided parameter settings. Bend: {'NAME': 'B1', 'AT_ENTRY': <Quantity(0, 'meter')>, 'AT_CENTER': <Quantity(0, 'meter')>, 'AT_EXIT': <Quantity(0, 'meter')>, 'APERTYPE': None, 'APERTURE': [], 'KINEMATICS': None, 'ANGLE': <Quantity(30, 'degree')>, 'K0': <Quantity(0.0, '1 / meter')>, 'K1': <Quantity(3, '1 / meter 2')>, 'K2': <Quantity(0.0, '1 / meter 3')>, 'L': <Quantity(1, 'meter')>, 'E1': <Quantity(5, 'degree')>, 'E2': <Quantity(0.0, 'radian')>, 'TILT': <Quantity(0.0, 'radian')>, 'HGAP': <Quantity(2, 'centimeter')>, 'FINT': 0.0, 'FINTX': 0.0}
Hello, I have fixed the bug in the 'develop' branch. As it is an important issue, I will make a new release of Georges once everything is in order. Concerning the energy degradation, you can adjust the strength of the magnet with the parameter $K0 = (1/B\rho) * B_y$
To verify the behavior of the beam, you can use a MeanObserver. You can find below an example with a screenshot of the mean position of the beam along the beamline. As you can see, I have slightly adjusted the default K0 value and the beam is completely offseted.
import georges
from georges import ureg as _ureg
from georges.manzoni.beam import MadXBeam
import matplotlib.pyplot as plt
from georges import vis
from georges.manzoni import Input, observers
d1 = georges.Element.Drift(
NAME="D1",
L=2.145 * _ureg.m,
APERTYPE="CIRCULAR",
APERTURE=[3.645 * _ureg.cm, 3.645 * _ureg.cm],
)
B3G2 = georges.Element.SBend(
NAME="B2G2",
L=1.492 * _ureg.m,
ANGLE=-90 * _ureg.degrees,
K1=0 * _ureg.m**-2,
APERTYPE="RECTANGULAR",
APERTURE=[5 * _ureg.cm, 2.8 * _ureg.cm],
HGAP=0.0315 * _ureg.m,
E1=-0.4346*_ureg.radians,
E2=-0.2889*_ureg.radians,
K0 = -0.97*1.0528125514711102/_ureg.m,
FINT=0.5,
FINTX=0.5
)
sequence = georges.PlacementSequence(name="Sequence")
sequence.place(d1, at_entry=0 * _ureg.m)
sequence.place_after_last(B3G2)
kin = georges.Kinematics(250 * _ureg.MeV, particle=georges.particles.Proton, kinetic=True)
sequence.metadata.kinematics = kin
beam = MadXBeam(
kinematics=kin,
distribution=georges.Distribution.from_twiss_parameters(
n=1000, x = 2.5 * _ureg.mm, y=2.5 * _ureg.mm, emitx=7 * _ureg.mm * _ureg.mradians, emity=7 * _ureg.mm* _ureg.mradians
).distribution.values,
)
mi = Input.from_sequence(sequence=sequence)
mi.freeze()
beam_observer_mean = mi.track(beam=beam, observers=observers.MeanObserver())
fig = plt.figure(figsize=(10,4))
ax = fig.add_subplot(111)
manzoni_plot = vis.ManzoniMatplotlibArtist(ax=ax)
manzoni_plot.plot_beamline(sequence.df, with_cartouche=True, print_label=True, with_aperture=True)
manzoni_plot.tracking(beam_observer_mean, plane="X")
plt.show()
Another point for the definition of a SBend
, you have to set units to the edge angles as follows:
import georges
from georges import Element
from georges import ureg as _ureg
B3G2 = Element.SBend('A', L=1*_ureg.m,
HGAP=5*_ureg.cm,
E1=-0.4346 * _ureg.radians,
E2=-0.2889 * _ureg.radians)
@rtesse Hello, Thank you for patiently resolving my issue patiently and quickly. If Georges has made any relevant updates, please remind me. I will use some ML technologies combined with the beamline constructed by Georges.
Hello, I made a new release of georges (2024.2). It fixes the bug you mentioned about the HGAP. I also improve the documentation. Could you tell me if everything goes well ? Is so, could you please close this issue ? Regards. Robin
@rtesse Hi! I tried the latest version and all the previous bugs were resolved. Thank you so much!!!
I haven't used the relevant software yet, I just skimmed through the tutorials and related papers. I have a few questions about Georges: