Commit e8e4532a by Chris Kerr

### Merge branch 'master' into alm-add-vector-dot

parents 1bf87c99 db67ed54
 # GALUMPH # # 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. 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
 ... @@ -56,7 +56,8 @@ class AtomAlm: ... @@ -56,7 +56,8 @@ class AtomAlm: def __init__(self, LMAX, s, worksize=64, natwork=16): def __init__(self, LMAX, s, worksize=64, natwork=16): assert LMAX >= 0 assert LMAX >= 0 self.LMAX = LMAX self.LMAX = LMAX NS, = np.shape(s) s = np.asanyarray(s) NS, = s.shape assert NS > 0 assert NS > 0 assert np.all(s >= 0) assert np.all(s >= 0) self.NS = NS self.NS = NS ... @@ -86,6 +87,7 @@ class AtomAlm: ... @@ -86,6 +87,7 @@ class AtomAlm: NS = self.NS NS = self.NS worksize = self.worksize worksize = self.worksize ff = np.asanyarray(ff) if np.isscalar(ff): if np.isscalar(ff): ff = np.ones_like(self.s) * ff ff = np.ones_like(self.s) * ff else: else: ... @@ -119,6 +121,7 @@ class AtomAlm: ... @@ -119,6 +121,7 @@ class AtomAlm: assert natoms > 0 assert natoms > 0 assert ndim == 3 assert ndim == 3 ff = np.asanyarray(ff) if np.ndim(ff) == 1: if np.ndim(ff) == 1: ff = np.ones_like(self.s) * ff[:, np.newaxis] ff = np.ones_like(self.s) * ff[:, np.newaxis] assert np.shape(ff) == (natoms, NS) assert np.shape(ff) == (natoms, NS) ... ...
 ... @@ -26,6 +26,7 @@ class SphericalBessel: ... @@ -26,6 +26,7 @@ class SphericalBessel: the worksize parameter. LMAX should be a positive integer.""" the worksize parameter. LMAX should be a positive integer.""" assert LMAX >= 0 assert LMAX >= 0 self.LMAX = LMAX self.LMAX = LMAX s = np.asanyarray(s) NS, = s.shape NS, = s.shape assert NS > 0 assert NS > 0 assert np.all(s >= 0) assert np.all(s >= 0) ... ...
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!