Skip to Content.
Sympa Menu

opal - Re: [Opal] Convert external particle distribution weighted by different macro charges to OPAL

opal AT lists.psi.ch

Subject: The OPAL Discussion Forum

List archive

Re: [Opal] Convert external particle distribution weighted by different macro charges to OPAL


Chronological Thread  
  • From: Simon Friederich <sifriede AT uni-mainz.de>
  • To: Christof Metzger-Kraus <christof.j.kraus AT gmail.com>
  • Cc: opal <opal AT lists.psi.ch>
  • Subject: Re: [Opal] Convert external particle distribution weighted by different macro charges to OPAL
  • Date: Wed, 16 Sep 2020 18:30:47 +0200
  • Authentication-results: localhost; iprev=pass (ironport-1.zdv.net) smtp.remote-ip=134.93.178.241; spf=pass smtp.mailfrom=uni-mainz.de; dkim=pass header.d=uni-mainz.de header.s=20190702 header.a=rsa-sha256; dmarc=pass header.from=uni-mainz.de
  • Ironport-phdr: 9a23:m7zeARzJeTDQx8LXCy+O+j09IxM/srCxBDY+r6Qd0usSIvad9pjvdHbS+e9qxAeQG9mCtLQc0aGH7+igATVGvc/f9ihaMdRlbFwssY0uhQsuAcqIWwXQDcXBSGgEJvlET0Jv5HqhMEJYS47UblzWpWCuv3ZJQk2sfQV6Kf7oFYHMks+5y/69+4HJYwVPmTGxfa5+IA+5oAnMtMQam5duJrg+xhbNrXZDZuBayX91KV6JkBvw+8a98IR//yhMvv4q6tJNX7j9c6kkV7JTES4oM3oy5M3ltBnDSRWA634BWWgIkRRGHhbI4gjiUpj+riX1uOx92DKHPcLtVrA7RS6i76ZwRxD2jioMKiM0/3vWisx0i6JbvQ6hqhliyIPafI2ZKPxzdb7GcNgEWWROQNpeVy1ZAoO9cYQPCfYBPf1FpIX5vlcCsAeyCRWpCO7p1zRGhGL53bci3uo/HwHI3AsgEc8Nvnraotr6O6UdXvy0zKTT1zrPc+lb1C3h5IXGcB0sp+yHU7JqccrWzEkiDx7LjlSVqYziOTOey+QDs3Ka7+V+SO2glXQnqwBtrTiv28whjZLJhoMbylDe9CV23ps6KsOjRU5mZ96kEYJctySAOIt3RMMjQntktzskxbA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StUJhlRkpIWgnVZecOYE F8mjHenvNMEAG3R3hcR9bexNwgLcnTcYd3HChrWsH8gsZYKtzYPV5b2+lXgR6B089sXsSoO56+ NTUcNbVA5kN2yyx4ft+mVbbHm2LLHFPMHahab1gyR0p8oVj1Z7ABkf1R2x3nLSoD10qOsWsafn KpY=
  • Organization: Institut für Kernphysik, JGU Mainz

Hi Christof and Andreas,

My latest approach was exactly how you've described it Christof, with the exception that I use also a normal distribution in the longitudinal case too. As I export the CST distribution right after the acceleration region I guess this is still a good approximation.

So these are the steps that I use in python (numpy + pandas):

1. read the exported CST distribution

    distr_df = pd.read_csv(cst_distribution, delim_whitespace=True, names=cst_cols, comment="%")

2. use the macrocharges as weights to calculate the covariance matrix:

    distr_df['w'] = distr_df.macrocharge / (-1.602e-19) 
    cov = np.cov(distr_df[selected_cols], aweights=distr_df.w, rowvar=False)

3. create a new distribution from a multivariate normale distribution using a given mean value (basically: (0,0,0,0,0,beta*gamma)) and the covariance matrix:

    distr_new = np.random.default_rng().multivariate_normal(mean, cov, size=int(N_opal))
    output_df = pd.DataFrame(data="distr_new," columns=['x', 'px', 'y', 'py', 'z', 'pz'])

I have some slight discrepancies if I look e.g. at the envelope in a drift space (i.a. I observe slightly different rms divergences) but for now I think is a good solution.

Best regards
Simon


Am 16.09.2020 um 17:54 schrieb Christof Metzger-Kraus:
Hi Simon,

couldn't you use the longitudinal charge distribution as a pdf and resample the long. particle distribution with it. In transverse direction you would then use e.g. a gaussian distribution. For the momenta of the particles you would use the moments of the distribution. 

I haven't done this myself though.

Christof 

Simon Friederich <sifriede AT uni-mainz.de> schrieb am Mo., 14. Sep. 2020, 10:40:

Dear all,

From CST I can export a particle distribution. In contrast to OPAL (and propably most of the other available simulation codes):
CST weights the macro particles by different macro charges instead of having the same macro-charge for all particles. The number of particles is (almost) equally distributed (slightly influenced by the simulation accuracy).

I am thinking of a way to convert the CST distribution to one, that can be used in OPAL (using FROMFILE).
Has anyone faced this task before and has a method/script that (s)he might share?

[I've looked into the python script by Bettina Kuske and Dieter Faulbaum (HZB), that converts an ASTRA distribution to OPAL, but it's unfortunately not suitable as ASTRA has a const. macro-charge for all particles, right?]

Thanks again in advance.

Best regards,
Simon

P.S.: I am sorry, that I've opened a second request mail, but being able to convert CST distributions to OPAL would circumvent the DC acceleration problem (see my last listing mail) for now.

-- 
-----------------------------------
Dr. Simon Friederich
Helmholtz-Institut Mainz
Kollaboration B/ACID
Johannes Gutenberg-Universität Mainz
Staudingerweg 18
55128 Mainz, Deutschland

Tel.: +49 (0)6131 39-23160
E-Mail: sifriede AT uni-mainz.de
----------------------------------------
-- 
-----------------------------------
Dr. Simon Friederich
Helmholtz-Institut Mainz
Kollaboration B/ACID
Johannes Gutenberg-Universität Mainz
Staudingerweg 18
55128 Mainz, Deutschland

Tel.: +49 (0)6131 39-23160
E-Mail: sifriede AT uni-mainz.de
----------------------------------------



Archive powered by MHonArc 2.6.19.

Top of Page