ELogs/OhieMayenin: Difference between revisions
SimonJolly (talk | contribs) (Created page with "Electronic Log for Ohie Mayenin.") |
OhieMayenin (talk | contribs) |
||
(45 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
== To Do == | |||
=== High Priority === | |||
* Learn CAD conversion/import method, which is currently understood to be STEP to GDML conversion using python script - send Stewart STEP files. | |||
* Run the new version of the simulations provided by Jacinta. | |||
* Import different versions of the CAD model into BDSIM to test each new component. | |||
=== Low Priority === | |||
* Rerun Geant4 Clatterbridge simulation in full. | |||
* Update python analysis scripts. | |||
== Completed == | |||
==== Term 1 ==== | |||
* Background theory reading. | |||
* Literature review. | |||
* CAD model packaging. | |||
* Progress report. | |||
* Geant4 pencil beam example simulations. | |||
* Understand how to setup Geant4, BDSIM and Python environments on HEP Cluster. | |||
* Partially ran Geant4 simulation of CCC by Matthieu. | |||
* Fixed x11 forwarding issues. | |||
==== Term 2 ==== | |||
* Project interview. | |||
* Setup Python 2.7 environment. | |||
* Fixed plot view issues and reported pybdsim bug. | |||
* Fixed BDSIM OpenGL visualiser issues. | |||
* Ran atf2 example in full. | |||
* Created troubleshooting log and added more detail on fixing issues. | |||
* Verified new dose monitor version and scheduled Clatterbridge visit. | |||
* Modified CAD model to include updated physical measurements sent by Jacinta. | |||
* Obtained and visualised CCC BDSIM gmad files sent by Jacinta. | |||
* Performed optical analysis and tracking visualisation on CCC BDSIM simulation. | |||
* Visited Clatterbridge and took various measurements, including of the dose monitor enclosure. | |||
* Added updated dose monitors with enclosures and aluminium collimator to beamline model. | |||
== Troubleshooting Log and Useful Information == | |||
=== Setting up BDSIM envrionment === | |||
* Initially ran the following setup script: | |||
''$ source /unix/pbt/software/scripts/bdsim.sh'' | |||
which partially works but crashes when running pybdsim, giving a runtime error every time a pybdsim function is executed. The error I received was as follows: | |||
''h = _ROOT.Header() | |||
RuntimeError:Header::Header() | |||
could not resolve ::()'' | |||
I fixed this issue by instead running the following setup script: | |||
''$ source /unix/pbt/software/scripts/bdsim_setup_jc.sh'' | |||
which fixes the pybdsim runtime error issues. | |||
=== X11 Forwarding via SSH === | |||
* When using SSH to connect to Linux cluster from a Windows machine, X11 forwarding was not enabled. This meant that any graphical windows like ROOT TBrowser and BDSIM GUI could not be accessed. To get around this I use the Exceed client with X11-enabled client PuTTY. | |||
PuTTY for Windows was easily installed from the web. Exceed was installable from the UCL Software Database. | |||
The Exceed client must be opened before starting an ssh session via PuTTY. Once Exceed is open, open PuTTY and go to the SSH tab. Then, under the Auth tab, click on X11, and check the box "Enable X11 forwarding." Then, navigate back to the session tab and connect to plus1 by writing plus1.hep.ucl.ac.uk. A PuTTY terminal window will then open allowing you to input username and password as usual. | |||
=== BDSIM Visualiser using OpenGL === | |||
* Even after fixing this X11 issues, the BDSIM visualiser which renders the geometry in the BDSIM GUI was not working correctly, showing a static black screen. To fix this, I installed the Exceed extension Exceed 3D, also available from the UCL Software Database, which enables the OpenGL visualiser. Once Exceed 3D is installed, one must open Xconfig from the Exceed terminal and go to the OpenGL tab. Check that 'Enable OpenGL' is enabled, as well as the checkbox 'Direct Rendering'. For my setup, all boxes are checked except for 'Overlay Support'. | |||
=== Plotting with Pybdsim === | |||
* Pybdsim plots did not pop up in a graphical window when generated, even with X11 forwarding enabled. To force these plots to open, one must type the following: | |||
''>>> import matplotlib.pyplot as plt'' | |||
''>>> plt.show(block=False)'' | |||
Once can also use pyplot.savefig() to save these figures, as some pybdsim plot functions do not have any outputsavefile arguments. | |||
=== Plotting Phase Space === | |||
Laurie on how to overcome pybdsim bug when plotting beam phase space: | |||
There's a bug in our Python where we passed the wrong argument not as a keyword argument but just as the 2nd order and this results in the string 'output' being used for binning, which it can't do. This is fixed now for the next version of pybdsim. | |||
In the mean time, you can get around this with: | |||
''>>> import pybdsim'' | |||
''>>> d = pybdsim.Data.Load("haloprimaries.root")'' | |||
''>>> phaseSpaceData = pybdsim.Data.PhaseSpaceData(d)'' | |||
''>>> pybdsim.Plot.PhaseSpace(phaseSpaceData, outputfilename='output')'' | |||
=== BDSIM Optical Analysis and Event Visualisation === | |||
* Optical analysis allows us to compare the twiss parameters for horizontal and vertical beam components between BDSIM and MAD-x. | |||
* We start with gmad files containing the bdsim simulations and a tfs file containing the MAD-x beamline of magnetic components. | |||
First, run the simulation in batch mode with N primaries to produce the output output.root: | |||
''$ bdsim --file=input.gmad --ngenerate=N --outfile=output'' | |||
* On the output file, we can use rebdsim to produce new ROOT files that contain histograms and optical data. For example, to merge events into bins in order to generate histograms, we write the following to produce histograms.root: | |||
''$ rebdsimHistoMerge output.root histograms.root'' | |||
The output histograms.root can be opened in a ROOT TBrowser in order to view the histograms, or the histograms can be plotted using pybdsim, and then displayed or saved using matplotlib.pyplot. | |||
* To run the rebdsim optical analysis, we write the following to produce optics.root: | |||
''$ rebdsimOptics output.root optics.root'' | |||
* We can then use pybsdim on the output file optics.root and the .tfs file containing the MAD-x beam line to create a series of plots comparing the beam size and twiss functions along with a machine diagram of the magnetic beamline, by using the following pybdsim function: | |||
''>>> pybdsim.Compare.MadxVsBDSIM('beamline.tfs', 'optics.root')'' | |||
* Once the optical analysis is done, we can try to visualise some of the events in the BDSIM GUI, by opening the simulation without the batch mode flag: | |||
''$ bdsim --file=input.gmad --outfile=data'' | |||
Then, in the BDSIM command line, we write | |||
''/run/beamOn 10'' | |||
which produces 10 events whose tracks are rendered in the GUI OpenGL display. | |||
* No more than ~100 events will be displayed at once due to memory constraints. | |||
* If a large simulation has been carried out in batch mode already, one can 'recreate' this in order to visualise a particular event in the BDSIM GUI, by writing the following: | |||
''$ bdsim --file=mymodel.gmad --outfile=data --recreate=originaldatafile.root -startFromEvent=5'' | |||
Then, in the BDSIM command line, we can write | |||
''/run/beamOn 1'' | |||
to render one event. | |||
=== Twiss Parameters and Tfs Diagrams === | |||
* The tfs machine diagram depicts quadrupoles using the following key: | |||
Above line - Horizontal focusing, vertical defocusing | |||
Below line - Horizontal defocusing, vertical focusing | |||
* The plots produced by rebdsim plot twiss parameters to describe the evolution of the beam. These parameters are based on MAD-X (Methodical Accelerator Design), which is a general-purpose tool for charged-particle optics design and is used in the study of beam lines. MAD-X succeeded MAD-8 and was specifically adapted to the needs of the LHC. | |||
* Twiss parameter definitions: | |||
Beta - beam size and reciprocal divergence | |||
Alpha - negative gradient of beta | |||
D_{x,y} - (assumption) position dispersion | |||
D_{p_x,p_y} - (assumption) momentum dispersion |
Latest revision as of 17:42, 13 March 2019
To Do
High Priority
- Learn CAD conversion/import method, which is currently understood to be STEP to GDML conversion using python script - send Stewart STEP files.
- Run the new version of the simulations provided by Jacinta.
- Import different versions of the CAD model into BDSIM to test each new component.
Low Priority
- Rerun Geant4 Clatterbridge simulation in full.
- Update python analysis scripts.
Completed
Term 1
- Background theory reading.
- Literature review.
- CAD model packaging.
- Progress report.
- Geant4 pencil beam example simulations.
- Understand how to setup Geant4, BDSIM and Python environments on HEP Cluster.
- Partially ran Geant4 simulation of CCC by Matthieu.
- Fixed x11 forwarding issues.
Term 2
- Project interview.
- Setup Python 2.7 environment.
- Fixed plot view issues and reported pybdsim bug.
- Fixed BDSIM OpenGL visualiser issues.
- Ran atf2 example in full.
- Created troubleshooting log and added more detail on fixing issues.
- Verified new dose monitor version and scheduled Clatterbridge visit.
- Modified CAD model to include updated physical measurements sent by Jacinta.
- Obtained and visualised CCC BDSIM gmad files sent by Jacinta.
- Performed optical analysis and tracking visualisation on CCC BDSIM simulation.
- Visited Clatterbridge and took various measurements, including of the dose monitor enclosure.
- Added updated dose monitors with enclosures and aluminium collimator to beamline model.
Troubleshooting Log and Useful Information
Setting up BDSIM envrionment
- Initially ran the following setup script:
$ source /unix/pbt/software/scripts/bdsim.sh
which partially works but crashes when running pybdsim, giving a runtime error every time a pybdsim function is executed. The error I received was as follows:
h = _ROOT.Header() RuntimeError:Header::Header() could not resolve ::()
I fixed this issue by instead running the following setup script:
$ source /unix/pbt/software/scripts/bdsim_setup_jc.sh
which fixes the pybdsim runtime error issues.
X11 Forwarding via SSH
- When using SSH to connect to Linux cluster from a Windows machine, X11 forwarding was not enabled. This meant that any graphical windows like ROOT TBrowser and BDSIM GUI could not be accessed. To get around this I use the Exceed client with X11-enabled client PuTTY.
PuTTY for Windows was easily installed from the web. Exceed was installable from the UCL Software Database.
The Exceed client must be opened before starting an ssh session via PuTTY. Once Exceed is open, open PuTTY and go to the SSH tab. Then, under the Auth tab, click on X11, and check the box "Enable X11 forwarding." Then, navigate back to the session tab and connect to plus1 by writing plus1.hep.ucl.ac.uk. A PuTTY terminal window will then open allowing you to input username and password as usual.
BDSIM Visualiser using OpenGL
- Even after fixing this X11 issues, the BDSIM visualiser which renders the geometry in the BDSIM GUI was not working correctly, showing a static black screen. To fix this, I installed the Exceed extension Exceed 3D, also available from the UCL Software Database, which enables the OpenGL visualiser. Once Exceed 3D is installed, one must open Xconfig from the Exceed terminal and go to the OpenGL tab. Check that 'Enable OpenGL' is enabled, as well as the checkbox 'Direct Rendering'. For my setup, all boxes are checked except for 'Overlay Support'.
Plotting with Pybdsim
- Pybdsim plots did not pop up in a graphical window when generated, even with X11 forwarding enabled. To force these plots to open, one must type the following:
>>> import matplotlib.pyplot as plt
>>> plt.show(block=False)
Once can also use pyplot.savefig() to save these figures, as some pybdsim plot functions do not have any outputsavefile arguments.
Plotting Phase Space
Laurie on how to overcome pybdsim bug when plotting beam phase space:
There's a bug in our Python where we passed the wrong argument not as a keyword argument but just as the 2nd order and this results in the string 'output' being used for binning, which it can't do. This is fixed now for the next version of pybdsim.
In the mean time, you can get around this with:
>>> import pybdsim
>>> d = pybdsim.Data.Load("haloprimaries.root")
>>> phaseSpaceData = pybdsim.Data.PhaseSpaceData(d)
>>> pybdsim.Plot.PhaseSpace(phaseSpaceData, outputfilename='output')
BDSIM Optical Analysis and Event Visualisation
- Optical analysis allows us to compare the twiss parameters for horizontal and vertical beam components between BDSIM and MAD-x.
- We start with gmad files containing the bdsim simulations and a tfs file containing the MAD-x beamline of magnetic components.
First, run the simulation in batch mode with N primaries to produce the output output.root:
$ bdsim --file=input.gmad --ngenerate=N --outfile=output
- On the output file, we can use rebdsim to produce new ROOT files that contain histograms and optical data. For example, to merge events into bins in order to generate histograms, we write the following to produce histograms.root:
$ rebdsimHistoMerge output.root histograms.root
The output histograms.root can be opened in a ROOT TBrowser in order to view the histograms, or the histograms can be plotted using pybdsim, and then displayed or saved using matplotlib.pyplot.
- To run the rebdsim optical analysis, we write the following to produce optics.root:
$ rebdsimOptics output.root optics.root
- We can then use pybsdim on the output file optics.root and the .tfs file containing the MAD-x beam line to create a series of plots comparing the beam size and twiss functions along with a machine diagram of the magnetic beamline, by using the following pybdsim function:
>>> pybdsim.Compare.MadxVsBDSIM('beamline.tfs', 'optics.root')
- Once the optical analysis is done, we can try to visualise some of the events in the BDSIM GUI, by opening the simulation without the batch mode flag:
$ bdsim --file=input.gmad --outfile=data
Then, in the BDSIM command line, we write
/run/beamOn 10
which produces 10 events whose tracks are rendered in the GUI OpenGL display.
- No more than ~100 events will be displayed at once due to memory constraints.
- If a large simulation has been carried out in batch mode already, one can 'recreate' this in order to visualise a particular event in the BDSIM GUI, by writing the following:
$ bdsim --file=mymodel.gmad --outfile=data --recreate=originaldatafile.root -startFromEvent=5
Then, in the BDSIM command line, we can write
/run/beamOn 1
to render one event.
Twiss Parameters and Tfs Diagrams
- The tfs machine diagram depicts quadrupoles using the following key:
Above line - Horizontal focusing, vertical defocusing
Below line - Horizontal defocusing, vertical focusing
- The plots produced by rebdsim plot twiss parameters to describe the evolution of the beam. These parameters are based on MAD-X (Methodical Accelerator Design), which is a general-purpose tool for charged-particle optics design and is used in the study of beam lines. MAD-X succeeded MAD-8 and was specifically adapted to the needs of the LHC.
- Twiss parameter definitions:
Beta - beam size and reciprocal divergence
Alpha - negative gradient of beta
D_{x,y} - (assumption) position dispersion
D_{p_x,p_y} - (assumption) momentum dispersion