Skip to content

Commit

Permalink
add readme
Browse files Browse the repository at this point in the history
  • Loading branch information
zhangt58 committed May 31, 2016
1 parent 56e0a17 commit 96726ee
Show file tree
Hide file tree
Showing 78 changed files with 86,383 additions and 116 deletions.
41 changes: 30 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,35 @@

Data post-processing and optimization scripts/programms for free-electron laser simulating code (Genesis 1.3) written in C/C++, Octave (Matlab) and Python.

upload to bitbucket on Jan. 24th, 2014.

migrate to github on May. 22nd, 2015.
#####Log:
* 2014-01-24: upload to bitbucket
* 2015-05-22: migrate to github
* 2016-05-31: add more READMEs and scripts/programs

#### contents:
* [Getdp](/Getdp): ![C/C++](https://img.shields.io/badge/C-C%2B%2B-brightgreen.svg)
, Extract data block from time-dependent output files, according to the slice order or z order, regarding to options.
* [PhaseShift](/PhaseShift): ![C/C++](https://img.shields.io/badge/C-C%2B%2B-brightgreen.svg)
, Simulating phase shift between electron bunch and radiation field.
* [Readdpa](/Readdpa): ![C/C++](https://img.shields.io/badge/C-C%2B%2B-brightgreen.svg)
, extract data from .dpa files
* [calpulse](/calpulse): ![bash](https://img.shields.io/badge/shell-bash-brightgreen.svg), calculate pulse energy and average pulse power, utilizing <code>getdp_s</code> and <code>getdp_z</code>
* [optimizatoinSuite](/optimizationSuite):
* [getdp](/getdp): ![C/C++](https://img.shields.io/badge/C-C%2B%2B-brightgreen.svg),
Extract data block from time-dependent output files, according to the slice order or z order, regarding to options.
* [phaseshifter](/phaseshifter): ![C/C++](https://img.shields.io/badge/C-C%2B%2B-brightgreen.svg),
Simulating phase shift between electron bunch and radiation field.
* [readdpa](/readdpa): ![C/C++](https://img.shields.io/badge/C-C%2B%2B-brightgreen.svg),
Extract data from .dpa files.
* [calpulse](/calpulse): ![bash](https://img.shields.io/badge/shell-bash-brightgreen.svg), ![python](https://img.shields.io/badge/python-2.7-brightgreen.svg),
Calculate pulse energy and average pulse power, utilizing <code>getdp_s</code> and <code>getdp_z</code> (shell version) and more efficient Python version (calpulse.py).
* [optimizationSuite](/optimizationSuite): ![bash](https://img.shields.io/badge/shell-bash-brightgreen.svg),
Parameters optimization scripts.
* [postProcessorM](/postProcessorM): [!octave](https://img.shields.io/badge/matlab-octave-brightgreen.svg),
Octave/matlab scripts for handle dpa and dfl binary files.
* [readdpa_tdp](/readdpa_tdp): ![C/C++](https://img.shields.io/badge/C-C%2B%2B-brightgreen.svg),
Read .dpa files and provide additional information.
* [readfld_tdp](/readfld_tdp): [!octave](https://img.shields.io/badge/matlab-octave-brightgreen.svg),
Read .dfl binary file, to calculate the projected angular distribution.
* [seed_gen](/seed_gen): [!octave](https://img.shields.io/badge/matlab-octave-brightgreen.svg), ![bash](https://img.shields.io/badge/shell-bash-brightgreen.svg),
Generate seed laser file for genesis 1.3 (radfile).
* [spectralAnalysis](/spectralAnalysis): [!octave](https://img.shields.io/badge/matlab-octave-brightgreen.svg), ![bash](https://img.shields.io/badge/shell-bash-brightgreen.svg),
Calculate spectral data file from TDP output file.
* [beta match](/beta_match): [!octave](https://img.shields.io/badge/matlab-octave-brightgreen.svg), ![bash](https://img.shields.io/badge/shell-bash-brightgreen.svg),
Twiss parameters matching for SASE, HGHG, EEHG, etc.




116 changes: 116 additions & 0 deletions beta_match/MEEHG/beta_EEHG.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
#!/bin/bash
#==========================================================================
#
# FILE: beta_EEHG.sh
#
# USAGE: beta_EEHG.sh QF QD
#
# DESCRIPTION: this script used to collect data from GENESIS *.in and
# *.lat for running script beta_script.m to find matched
# twiss parameters for modulator and radiator setup in EEHG.
#
# OPTIONS: need file fullat.EEHG
# REQUIREMENTS: ---
# BUGS: ---
# NOTES: ---
# AUTHOR: Tong Zhang (), [email protected]
# COMPANY: FEL physics Group, SINAP
# VERSION: 1.0
# CREATED: 03/06/2011 07:58:39 PM CST
# REVISION: 21:29, Jan. 19th, 2013
#==========================================================================
function creat_template()
{
cat <<EOF > fullat.EEHG
# Today is $(date)
#
# This file is a series of number separated by blanks,
# which describes the whole lattice of EEHG.
#
# Format :! n1 n2 n3 n4 n5 n6 n7 n8 n9 n10 n11 n12
# meaning: lo1 lm1 lo2 lo3 lm2 lo4 lo5 lqf lo6 lur lo7 lqd
# lo1: drift length before mod-1, unit: mod-1 period
# lm1: total length of mod-1, unit: mod-1 period
# lo2: drift length between mod-1 and chicane-1, unit: mod-1 period
# lo3: drift length before mod-2, unit: mod-2 period
# lm2: total length of mod-2, unit: mod-2 period
# lo4: drift length between mod-2 and chicane-2, unit: mod-2 period
# lo5: drift length before QF1,after chicane-2, unit: rad period
# lqf: 1st quadruplole length, unit: rad period
# lo6: drift length between QF1 and undulator, unit: rad period
# lur: section length of undulator, unit: rad period
# lo7: drift length between undulator and QF2(QD), unit: rad period
# lqd: 2nd quadruplole length, unit: rad period
# the full lattice will be:
# n1->n2->n3->[Chi-1]->n4->n5->n6->[Chi-2]->n7->n8->n9->n10->n11->n12
# O1->M1->O2->[Chi-1]->O3->M2->O4->[Chi-2]->O5->QF->O6->UR-->O7-->QD
# Theoretically : one FODO will be: n8/2 n9 n10 n11 n12 n9 n10 n11 n8/2
# schematic optics:
|----| |----| |----| _______ |----| |----| |----| _______
|-O1-|->|-M1-|->|-O2-|-->/[Chi-1]\-->|-O3-|->|-M2-|->|-O4-|-->/[Chi-2]\-->
|----| |----| |----| |----| |----| |----|
|----| |----| |----| |----| |----| |----|
---->|-O5-|->|-QF-|->|-O6-|->|-UR-|->|-O7-|->|-QD-|-->...
|----| |----| |----| |----| |----| |----|
# write lattice number from mod1 to rad after '!' the next line.
!
EOF
echo "Please fill the file fullat.EEHG, and run $0 again."
}

if [ ! -e fullat.EEHG ]
then
creat_template
exit 1
fi
a=$(grep ^! fullat.EEHG | sed 's/!//')
lo1=$(echo $a | awk '{print $1}')
lm1=$(echo $a | awk '{print $2}')
lo2=$(echo $a | awk '{print $3}')
lo3=$(echo $a | awk '{print $4}')
lm2=$(echo $a | awk '{print $5}')
lo4=$(echo $a | awk '{print $6}')
lo5=$(echo $a | awk '{print $7}')
lqf=$(echo $a | awk '{print $8}')
lo6=$(echo $a | awk '{print $9}')
lur=$(echo $a | awk '{print $10}')
lo7=$(echo $a | awk '{print $11}')
lqd=$(echo $a | awk '{print $12}')

gamma0=$(grep -i gamma mod1.in | awk -F'=' '{print $NF}')
emitn=$(grep -i emitx mod1.in | awk -F'=' '{print $NF}')
if [ -e mod1.lat ]
then
am1=$(grep -i aw mod1.lat | awk '{print $2}')
lambdam1=$(grep -i unit mod1.lat | awk -F'=' '{print $NF}')
else
am1=$(grep -i aw0 mod1.in | awk -F'=' '{print $NF}')
lambdam1=$(grep -i xlamd mod1.in | grep -iv xlamds | awk -F'=' '{print $NF}')
fi

if [ -e mod2.lat ]
then
am2=$(grep -i aw mod2.lat | awk '{print $2}')
lambdam2=$(grep -i unit mod2.lat | awk -F'=' '{print $NF}')
else
am2=$(grep -i aw0 mod2.in | awk -F'=' '{print $NF}')
lambdam2=$(grep -i xlamd mod2.in | grep -iv xlamds | awk -F'=' '{print $NF}')
fi

imagl1=$(grep -i imagl mod2.in | awk -F'=' '{print $NF}')
idril1=$(grep -i idril mod2.in | awk -F'=' '{print $NF}')
ibfield1=$(grep -i ibfie mod2.in | awk -F'=' '{print $NF}')

imagl2=$(grep -i imagl rad.in | awk -F'=' '{print $NF}')
idril2=$(grep -i idril rad.in | awk -F'=' '{print $NF}')
ibfield2=$(grep -i ibfie rad.in | awk -F'=' '{print $NF}')



lambdau=$(grep -i unit rad.lat | awk -F'=' '{print $NF}')
au=$(grep -i aw0 rad.in | awk -F'=' '{print $NF}')

QF=$1
QD=$2
octave -qf beta_script.m ${QF} ${QD} ${gamma0} ${emitn} ${lambdam1} ${am1} ${lambdam2} ${am2} ${imagl1} ${idril1} ${ibfield1} ${imagl2} ${idril2} ${ibfield2} ${lambdau} ${au} ${lo1} ${lm1} ${lo2} ${lo3} ${lm2} ${lo4} ${lo5} ${lqf} ${lo6} ${lur} ${lo7} ${lqd}
Loading

0 comments on commit 96726ee

Please sign in to comment.