Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
E
ess-python-tools
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
External wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
ESS Beam Physics
ess-python-tools
Commits
54342089
Commit
54342089
authored
6 years ago
by
Yngve Levinsen
Browse files
Options
Downloads
Patches
Plain Diff
started on bdsim converter
parent
cfc9646f
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
ess/lib_tw.py
+15
-0
15 additions, 0 deletions
ess/lib_tw.py
ess/lib_tw_elem.py
+22
-1
22 additions, 1 deletion
ess/lib_tw_elem.py
with
37 additions
and
1 deletion
ess/lib_tw.py
+
15
−
0
View file @
54342089
...
@@ -344,6 +344,21 @@ class LATTICE:
...
@@ -344,6 +344,21 @@ class LATTICE:
except
AttributeError
:
except
AttributeError
:
pass
pass
def
get_bdsim
(
self
,
output_folder
=
'
bdsim
'
):
if
not
os
.
path
.
exists
(
output_folder
):
os
.
makedirs
(
output_folder
)
file_name
=
os
.
path
.
join
(
output_folder
,
'
bdsim.dat
'
)
if
self
.
lst
[
-
1
].
gamma
==
1.0
:
self
.
update_gamma
()
# Assign gamma, if not done yet
with
open
(
file_name
,
'
w
'
)
as
fname
:
for
fmap
in
self
.
fmap
:
fname
.
write
(
self
.
fmap
[
fmap
].
get_bdsim
(
os
.
path
.
join
(
output_folder
,
fmap
))
+
'
\n
'
)
for
lat_i
in
self
.
lst
:
if
hasattr
(
lat_i
,
'
get_bdsim
'
):
fname
.
write
(
lat_i
.
get_bdsim
()
+
'
\n
'
)
class
PROJECT
:
class
PROJECT
:
'''
'''
- This is for running multiple simulations 1-by-1 under 1 project.
- This is for running multiple simulations 1-by-1 under 1 project.
...
...
This diff is collapsed.
Click to expand it.
ess/lib_tw_elem.py
+
22
−
1
View file @
54342089
...
@@ -98,6 +98,7 @@ from __future__ import print_function
...
@@ -98,6 +98,7 @@ from __future__ import print_function
from
numpy
import
*
from
numpy
import
*
import
sys
import
sys
import
shutil
#---- Constants
#---- Constants
...
@@ -122,7 +123,15 @@ class FIELD_MAP_DATA:
...
@@ -122,7 +123,15 @@ class FIELD_MAP_DATA:
# Instances
# Instances
self
.
dL
=
float
(
lin
[
0
].
split
()[
1
])
/
int
(
lin
[
0
].
split
()[
0
])
self
.
dL
=
float
(
lin
[
0
].
split
()[
1
])
/
int
(
lin
[
0
].
split
()[
0
])
self
.
field
=
map
(
float
,
lin
[
2
:])
self
.
field
=
array
(
lin
[
2
:],
dtype
=
float
)
self
.
file_name
=
file_name
def
get_bdsim
(
self
,
path
):
# Only support 1D edz for now!
with
open
(
path
+
'
.txt
'
,
'
w
'
)
as
fmapout
:
for
i
in
range
(
len
(
self
.
field
)):
fmapout
.
write
(
'
{} {} {} {}
\n
'
.
format
(
self
.
dL
*
i
,
0.0
,
0.0
,
self
.
field
[
i
]))
return
'
{0}: field, type=
"
ebmap2d
"
, integrator=g4classicalrk4, electricFile=bdsim1d:{0}.txt;
'
.
format
(
self
.
file_name
[:
-
4
])
#---- Parent classes
#---- Parent classes
...
@@ -298,6 +307,9 @@ class FIELD_MAP(ELEM):
...
@@ -298,6 +307,9 @@ class FIELD_MAP(ELEM):
lin
+=
'
0 0 0 0 0
'
lin
+=
'
0 0 0 0 0
'
return
lin
return
lin
def
get_bdsim
(
self
):
return
'
element, geometryFile=
"
gdml:{0}.gdml
"
, fieldVacuum=
"
{0}
"
, l={1}
'
.
format
(
self
.
name_fmap
,
self
.
L
)
#---- Active elements
#---- Active elements
...
@@ -361,6 +373,10 @@ class DRIFT(ELEM):
...
@@ -361,6 +373,10 @@ class DRIFT(ELEM):
return
lin
return
lin
def
get_bdsim
(
self
):
return
'
drift, l={}*mm, beampipeRadius={}*mm;
'
.
format
(
self
.
L
,
self
.
apt
)
class
QUAD
(
ELEM
):
class
QUAD
(
ELEM
):
'''
'''
- Tilt not supported.
- Tilt not supported.
...
@@ -433,6 +449,11 @@ class QUAD(ELEM):
...
@@ -433,6 +449,11 @@ class QUAD(ELEM):
return
lin
return
lin
def
get_bdsim
(
self
):
return
'
quadrupole, l={}*mm, k1={}, beampipeRadius={}*mm;
'
.
format
(
self
.
L
,
self
.
G
/
Brho
(
self
.
gamma
),
self
.
apt
)
class
THIN_STEERING
(
ELEM
):
class
THIN_STEERING
(
ELEM
):
'''
'''
- Only magnetic steerer supported.
- Only magnetic steerer supported.
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment