Closed ColwynGulliford closed 1 year ago
To try and see if there is an issue, I'll install lume-GPT from conda and try the same commands:
Create a fresh conda environment:
Install lume-gpt:
Check main dependencies
Run notebooks:
The simple drift example works...
I found a more complicated example which seems to reproduce the error shown above:
It seems like the function Lattice.write_gpt_lines is sometimes not including a "\n" at the end of the lattice file line strings:
setfile("beam", "gpt_particles.gdf");time=0.0;auto_phase=0.0;space_charge=0.0;cathode=0.0;space_charge_type=1.0;RadiusMax=0.04;GBacc=5.5;xacc=6.5;accuracy(GBacc, xacc);dtmin=1e-16;dtmax=1e-10; Alpha=1.0;Fn=0.5;verror=0.005;Nstd=5.0;tree_code_theta=1.0;tree_code_R=1e-06;if (space_charge == 1) { if (space_charge_type == 1) { if(cathode == 1) { spacecharge3Dmesh("Cathode", "MeshNfac", Alpha, "MeshAdapt", Fn, "SolverAcc", verror, "MeshBoxSize", Nstd); } else { spacecharge3Dmesh("MeshNfac", Alpha, "MeshAdapt", Fn, "SolverAcc", verror, "MeshBoxSize", Nstd); } } if (space_charge_type == 2) { setrmacrodist("beam","u",tree_code_R,0) ; spacecharge3Dtree(tree_code_theta) ; } #if (space_charge_type == 3) { # spacechargeP2Pgpu("3D", "SinglePrecision"); # }}Ntout=50.0;tmax=10e-9;ZSTART=-0.005;ZSTOP=3;zminmax("wcs", "I", ZSTART, ZSTOP);if(Ntout>0) { tout(time, tmax, tmax/Ntout);}
# b1
I have found the difference: from gpt.element import Lattice
in multiple_runs.ipynb
seems to be the issue.
The working example provided uses from gpt.lattice import Lattice
which is a different Class. Why do we have two Lattice Classes?
The new class uses file_lines = [line+'\n' for line in BASIC_TEMPLATE]
on line 276 while the problematic class uses file_lines = BASIC_TEMPLATE
on line 785.
That is why I made a comment about """...""".split('\n') and missing \n
in the BASIC_TEMPLATE in my email to you.
The issue was importing a stale Lattice class definition from gpt.element
. Please import the Lattice class from gpt.lattice. I've removed the stale definition and will update the example notebooks accordingly.
Thank you, I am using gpt.lattice
definition now. I am still having issues running your multiple_runs.ipynb
example:
, workdir='temp'
option that would stop execution if user does not have 'temp' folder locally. I have created the folder and managed to move to the next issue.Error occured: True Cause: gpt: lume-gpt/examples/temp/gpt.temp.in(37): Error: Too many outputs
Yeah, I think the track1_to_z function hasn't been used in many years by anyone, so it probably needs some careful work. I would suggest not using it.
For now, I've removed the workdir = "temp"
lines and just deleted cell 7, as this wasn't relevant to that notebook anyways.
I'm running through the example notebooks and updating those as well and will make a new release when they check out.
User reports issue with GPT lattice template file: