Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Spontaneous Radiation Rises as Resolution increases #89

Open
Xuan0533 opened this issue Sep 11, 2024 · 2 comments
Open

Spontaneous Radiation Rises as Resolution increases #89

Xuan0533 opened this issue Sep 11, 2024 · 2 comments

Comments

@Xuan0533
Copy link

Xuan0533 commented Sep 11, 2024

I got trouble with the resolution setup. It is found that as the transverse resolution increases by increasing number of nodes keep, the spontaneous radiation continuous to increase with no end.

A specific image file is attached:
Screenshot 2024-09-10 222402

I would really appreciate if I can get some help!

@Xuan0533
Copy link
Author

Xuan0533 commented Sep 11, 2024

The input file:

&MDATA
  qOneD                  = .false.
  qScaled                = .false.  ! Using unscaled (S.I.) inputs
  sElectronThreshold     = 0.05
  qFocussing             = .true.   ! if focussing is included in the transverse plane
  qUndEnds               = .false.
  ioutInfo=3
  meshType  = 0          ! Full mesh
  sFModelLengthZ2        = 1.5674743331935322e-15
  sFModelLengthX         = 0.00025
  sFModelLengthY         = 0.00025
  nodesPerLambdar        = 20  ! <- Nodes per resonant wavelength in the temporal direction
  iNumNodesX             = 201
  iNumNodesY             = 201
  qFMesh_G = .false.            ! <- Auto-setup of the mesh: 
  srho                   = 0.00473540795492875
  saw                    = 3.0
  sgamma_r               = 8727.533
  lambda_w               = 0.03
  zundType               = 'helical'
  sZ0                    = 0.0
  stepsPerPeriod         = 30  ! Number of steps per wiggler period
  iWriteNthSteps         = 1500
  iWriteIntNthSteps      = 30
  qInitWrLat             = .false.
  qDumpEnd               = .false.
  Lattfile= 'FACET.latt'
  beam_file = 'FACET.beam'
/

The Beam file:

&NBLIST
nbeams = 1
dtype = 'simple'
/

&BLIST
sSigmaE = 1.1181e-5, 1.1181e-5, 1.1129e-16, 6.1339e-6, 6.1339e-6, 0.00065187
sLenE = 1.1181e-4, 1.1181e-4, 1.1129e-15, 6.1339e-5, 6.1339e-5, 0.0065187
bcenter = 0.0000
gammaf = 1.0
Ipk = 11964.77   ! Peak Current
alphax = 0.0   ! Twiss params...
alphay = 0.0
emitx = 7.3104e-11  ! geometric emittances...
emity = 7.3104e-11
TrLdMeth = 2
iMPsZ2PerWave = 20
nseqparts = 1000

The Lattice file:

QU -1.240 1.240
UN  'helical'  25   1.0   0.0   30   1.0   1.0   0.0    0.0
QU 0.620 -0.620
UN  'helical'  25   1.0   0.0   30   1.0   1.0   0.0    0.0
QU -1.240 1.240

@mightylorenzo
Copy link
Collaborator

Hmm..there's one or two possibilities here...

First of all, just a minor point, are you filtering the radiation field before plotting the power? This may all be low-frequency content, but I can't see a power spectrum so I don't know...usually it's OK since there is a high-pass filtering that Puffin itself does when running in 3D (defaulted at a 1/3rd of the resonant frequency, but it can be adjusted), but it can also depend on the temporal profile of the beam if it's short enough. Usually I'd actually just band-pass the field around the resonant frequency and also the harmonics separately if necessary, but it depends on what you're looking for and what scenario you're investigating.

Another thing is, the radiation field mesh uses an absorbing boundary of 16 nodes surrounding the outer edge on all sides. They are included in the mesh setup in the input file, so if you tell puffin to setup 100 nodes in the x-direction for the mesh, the inner 68 will be non-absorbing nodes surrounded by 16 absorbing nodes on each side (32 absorbing nodes in total). This number of absorbing nodes is currently fixed in puffin. If you have a lot of diffraction, then you may see power being sucked out of the system through the absorbing boundaries. Changing the grid spacing while keeping the length constant would change the length of the absorbing boundary, resulting in more or less power being absorbed by the boundaries.

I've not had a chance to look properly at the numbers, but if you have a lot of diffraction (Rayleigh range comparable to the undulator period) you may also find that calculating the diffraction step every period is not good enough. Having said that, I seem to recall that in practice this didn't seem to affect the results significantly even when the Rayleigh range was pretty much equal to the undulator period, but I may be remembering wrong :) . You can adjust the diffraction step size with the 'sDiffFrac' variable in the main input file. It is the length of the diffraction step expressed in units of the undulator period, defaulted to 1. You could try reducing it. Worst case is calculating a diffraction step at the end of every RK4 temporal-longitudinal step (sDiffFrac = 0.03333333333333333)...this will massively increase your simulation time...so I hope it's not that...

The last thing I can think of is simply an under-sampling of the beam compared to the radiation grid. My quick (maybe wrong) calc from looking at the input file looks like there's roughly 10,000 transverse grid elements (100 in x and 100 in y) and only 1000 randomly distributed (OK, well it's a Halton sequence but almost :) ) macroparticles for each slice in the transverse direction....for context, the way I usually set it up is to have the beam contained within around 20 or so nodes in the centre of the grid in each of x and y when using 1000 macroparticles in each transverse slice. In the example file you gave, the beam may not be being properly sampled by the field, if that makes any sense. This interplay between the beam and grid sampling is crucial, rather than the absolute individual sampling of the beam and field grid. Maybe my numbers for the file here are incorrect...but as I say I'd aim to have about 20 or so nodes in the centre of the grid in each of x and y sampling the beam here (usually 5 or 6 times the standard deviation if it's a Gaussian beam), with the outer nodes there to allow for the field diffraction (usually 64 or 128 total, but depends on the amount of diffraction you need to model). With a Gaussian in x and y that's fine, adding more doesn't give you much, if any, benefit (certainly not worth the extra compute tbh). OTOH maybe your focussing system is causing the beam to stretch/contract significantly in x or y across the length of the undulator but hopefully this can point you in the right direction.

I'd suggest testing this in periodic mode if you're not already - you'll be able test all this relatively quickly to pin down/eliminate the transverse variations you're investigating before moving to a full-fat simulation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants