Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
grp-svergun
galumph
Commits
e8e4532a
Commit
e8e4532a
authored
Feb 21, 2017
by
Chris Kerr
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' into alm-add-vector-dot
parents
1bf87c99
db67ed54
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
32 additions
and
2 deletions
+32
-2
README.md
README.md
+27
-1
galumph/atomalm.py
galumph/atomalm.py
+4
-1
galumph/sphericalbessel.py
galumph/sphericalbessel.py
+1
-0
No files found.
README.md
View file @
e8e4532a
# GALUMPH #
Calculate ALM (scattering amplitude decomposed into spherical harmonics) using GPU acceleration.
Calculate ALM (scattering amplitude decomposed into spherical harmonics)
at Hyperspeed
using GPU acceleration.
This is a preliminary implementation using PyOpenCL.
Example code:
```
python
import
numpy
as
np
import
Bio.PDB
import
periodictable
import
galumph
NS
=
4096
# Number of S values at which to calculate the scattering
smax
=
1.0
# Maximum S value
LMAX
=
63
# Maximum harmonic order to use for the calculations
## Initialise the S array and allocate the ALM storage on the GPU
s
=
np
.
linspace
(
0
,
smax
,
NS
)
atomalm
=
galumph
.
AtomAlm
(
LMAX
,
s
)
## Use Bio.PDB to read the structure and periodictable to calculate the atomic form factors
pdb
=
Bio
.
PDB
.
PDBParser
().
get_structure
(
"6lyz"
,
"6lyz.pdb"
)
xyz
=
np
.
array
([
aa
.
get_vector
().
get_array
()
for
aa
in
pdb
.
get_atoms
()])
ff
=
np
.
array
([
periodictable
.
elements
.
symbol
(
aa
.
element
).
xray
.
f0
(
s
)
for
aa
in
pdb
.
get_atoms
()])
## Run the GPU calculation
atomalm
.
add_many_atoms
(
xyz
,
ff
)
Icalc
=
atomalm
.
sum_intensity
()
```
\ No newline at end of file
galumph/atomalm.py
View file @
e8e4532a
...
...
@@ -56,7 +56,8 @@ class AtomAlm:
def
__init__
(
self
,
LMAX
,
s
,
worksize
=
64
,
natwork
=
16
):
assert
LMAX
>=
0
self
.
LMAX
=
LMAX
NS
,
=
np
.
shape
(
s
)
s
=
np
.
asanyarray
(
s
)
NS
,
=
s
.
shape
assert
NS
>
0
assert
np
.
all
(
s
>=
0
)
self
.
NS
=
NS
...
...
@@ -86,6 +87,7 @@ class AtomAlm:
NS
=
self
.
NS
worksize
=
self
.
worksize
ff
=
np
.
asanyarray
(
ff
)
if
np
.
isscalar
(
ff
):
ff
=
np
.
ones_like
(
self
.
s
)
*
ff
else
:
...
...
@@ -119,6 +121,7 @@ class AtomAlm:
assert
natoms
>
0
assert
ndim
==
3
ff
=
np
.
asanyarray
(
ff
)
if
np
.
ndim
(
ff
)
==
1
:
ff
=
np
.
ones_like
(
self
.
s
)
*
ff
[:,
np
.
newaxis
]
assert
np
.
shape
(
ff
)
==
(
natoms
,
NS
)
...
...
galumph/sphericalbessel.py
View file @
e8e4532a
...
...
@@ -26,6 +26,7 @@ class SphericalBessel:
the worksize parameter. LMAX should be a positive integer."""
assert
LMAX
>=
0
self
.
LMAX
=
LMAX
s
=
np
.
asanyarray
(
s
)
NS
,
=
s
.
shape
assert
NS
>
0
assert
np
.
all
(
s
>=
0
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment