hightower8083/chimera

there is no output results of the script in ./doc/test/lpa_testrun.py

QJohn2017 opened this issue · 5 comments

Hi, I am the first time to use the Chimera, I have installed it successfully. And I tried to test the script in ./doc/test files. My test script file is lpa_testrun.py. The program seems runs well. But there is no output results. I think it can be set in the input file:
Diags = Diagnostics(Chimera, (), out_folder='diags')

But I don't know how to set this. Besides, I opened the dignostics.py file in ./moduls, I found that:
`class Diagnostics:
def init(self,Chimera, diags=(), out_folder=None):
self.Chimera = Chimera
self.diags = diags
if out_folder!=None:
self.out_folder = out_folder
os.system('rm -rf ' + self.out_folder)
os.system('mkdir ' + self.out_folder)

def do_diags(self,i):
	for diag in self.diags:
		if np.mod(i,diag['Step'])!=0: continue
		self.istr = str(i)
		while len(self.istr)<7: self.istr='0'+self.istr
		if 'Features' not in diag: diag['Features'] = {}

		if diag['Type']=='Fields'   : self.fld_out(diag)
		if diag['Type']=='FieldsFB' : self.fldfb_out(diag)
		if diag['Type']=='Particles': self.phs_out(diag)
		if diag['Type']=='Density'  : self.dns_out(diag)
		if diag['Type']=='EnergyEM' : self.nrg_out(diag)
		if diag['Type']=='Power'    : self.pwr_out(diag)

I found that the key is the functiondo_diags`, but I don't find where it gets called.

So, can you provide a more detial input script file including the output controlling module? Thank you very much !

Dear @QJohn2017

Thank you for your interest in this code! I have not been maintaining it for a while and first thing I suggest to consider using dev branch (!) -- master is rather obsolete in most features including documentation (i should have removed it).

Tests in ./doc/test/ are meant to be quick integrity checks, i.e. just to see if code doesn't crash, and indeed don't produce any data. The much more sensible examples can be found in the demo notebooks in ./doc/ -- if you have jupyter I suggest to start with them, fel-lpa-demo.ipynb should be particularly instructive.

In these demos diagnostics are used interactively as shortcuts to the access data, e.g. Diags.dns_out( {'Features':('Return',)} ) returns density distribution. In order to write the files, for example fields and density distributions, one need to define Diags = Diagnostics(Chimera, ('Fields', 'Density' ), out_folder='diags'), and than add a call in the main loop to write the files:

for i in range(1,SimulationSteps+1):
    Chimera.make_step(i)
    if np.mod(i, diag_step)==0:
        Diags.do_diags(i)

If you need more details, please tell which functionality of the code you are interested in:

  • laser-plasma PIC simulations
  • free electron laser simulation (includes separate space-charge solver)
  • synchrotron radiation calculation

Code is rather an academic project than a production tool, and thus some features are not well optimised. For example its PIC functionality (also available in chimeraCL) is greatly surpassed by FBPIC, and its far-field synchrotron radiation module is revised in synchrad. IMHO, FEL is the only feature which is remains interesting and has unique capabilities compared to the existing open-source solutions.

Dear @hightower8083
Thank you very much for so kind to give me a reply. My Interesting to use this program is the FEL simulation. In fact, I want to simulate the FEL process of the electron beams generated by the LWFA . You know that the traditional FEL simulation by genesis is not siutablbe for the electron beams from LWFA. So , I want to use this Chimera program to do this. So, how can I realize my goal ? Thank you again !

Dear @QJohn2017
The modelling strategy depends on your particular setup -- if you consider undulator section directly after LWFA, or if there is some transport line to shape the beam. In the second case in between PIC and FEL simulation you will need to model beam propagation through beam optics (dipole/quadrupole magnets). I have used the code in the latter context in this paper and after the transport beam was smooth enough so model with GENESIS agreed with CHIMERA one pretty well (Fig 5, Fig 8). On the other hand with CHIMERA we could also do a more accurate model with the measured undulator field (Figs 16-17)
To start with that you will need to produce a beam (~10^5 model particles) at the undulator entrence, and set up the undulator field. You can see how it is done in the first section of this example.

@QJohn2017, I will close this issue for now.
For particular questions concerning setting up FEL simulations, you may write me an email.
imho, the existing example gives enough info to start playing. Unless someone would suggest (or better provide) any particular cases to add, and i'm not planning to extend documentation in the near future.

Okay, thank you very much !