All pastes #1915427 Raw Edit

christian

public text v1 · immutable
#1915427 ·published 2010-08-12 00:00 UTC
rendered paste body
Index: gpaw/io/__init__.py===================================================================--- gpaw/io/__init__.py	(revision 6958)+++ gpaw/io/__init__.py	(working copy)@@ -487,6 +487,10 @@      hdf5 = hasattr(r, 'hdf5_reader') +    par_kwargs = {}+    if hdf5:+        par_kwargs.update({'parallel': True, 'read': True}) #XXX read on master only?+     for setup in wfs.setups.setups.values():         try:             key = atomic_names[setup.Z] + 'Fingerprint'@@ -509,7 +513,7 @@     nt_sG = wfs.gd.empty(density.nspins)     if hdf5:         indices = [slice(0, density.nspins),] + wfs.gd.get_slice()-        nt_sG[:] = r.get('PseudoElectronDensity', *indices)+        r.get('PseudoElectronDensity', *indices, out=nt_sG, parallel=True) #XXX read=?     else:         for s in range(density.nspins):             wfs.gd.distribute(r.get('PseudoElectronDensity', s),@@ -534,7 +538,7 @@         hamiltonian.vt_sG = wfs.gd.empty(hamiltonian.nspins)         if hdf5:             indices = [slice(0, hamiltonian.nspins), ] + wfs.gd.get_slice()-            hamiltonian.vt_sG[:] = r.get('PseudoPotential', *indices)+            r.get('PseudoPotential', *indices, out=hamiltonian.vt_sG, parallel=True) #XXX read?         else:             for s in range(hamiltonian.nspins):                 wfs.gd.distribute(r.get('PseudoPotential', s),@@ -560,7 +564,7 @@         hamiltonian.Eext = 0.0     hamiltonian.Exc = r['Exc']     hamiltonian.S = r['S']-    hamiltonian.Etot = r.get('PotentialEnergy') - 0.5 * hamiltonian.S+    hamiltonian.Etot = r.get('PotentialEnergy', **par_kwargs) - 0.5 * hamiltonian.S      wfs.rank_a = np.zeros(natoms, int) @@ -597,7 +601,7 @@         if hasattr(paw, attr):             try:                 if r.has_array(name):-                    value = r.get(name)+                    value = r.get(name, **par_kwargs)                 else:                     value = r[name]                 setattr(paw, attr, value)@@ -624,8 +628,8 @@             timer.start('Band energies')             k = kpt.k             s = kpt.s-            eps_n = r.get('Eigenvalues', s, k)-            f_n = r.get('OccupationNumbers', s, k)+            eps_n = r.get('Eigenvalues', s, k, **par_kwargs)+            f_n = r.get('OccupationNumbers', s, k, **par_kwargs)             kpt.eps_n = eps_n[nslice].copy()             kpt.f_n = f_n[nslice].copy()             timer.stop('Band energies')@@ -635,8 +639,8 @@                 kpt.ne_o = np.empty(norbitals, dtype=float)                 kpt.c_on = np.empty((norbitals, wfs.mynbands), dtype=complex)                 for o in range(norbitals):-                    kpt.ne_o[o] = r.get('LinearExpansionOccupations',  s, k, o)-                    c_n = r.get('LinearExpansionCoefficients', s, k, o)+                    kpt.ne_o[o] = r.get('LinearExpansionOccupations',  s, k, o, **par_kwargs)+                    c_n = r.get('LinearExpansionCoefficients', s, k, o, **par_kwargs)                     kpt.c_on[o,:] = c_n[nslice]                 timer.stop('dSCF expansions') @@ -647,7 +651,7 @@             paw.input_parameters.mode == 'fd'):              timer.start('Pseudo-wavefunctions')-            if band_comm.size == 1 and not hdf5:+            if band_comm.size == 1 and not hdf5: #XXX implement HDF5 mounting                 # We may not be able to keep all the wave                 # functions in memory - so psit_nG will be a special type of                 # array that is really just a reference to a file:@@ -662,7 +666,7 @@                         indices = [kpt.s, kpt.k]                         indices.append(wfs.bd.get_slice())                         indices += wfs.gd.get_slice()-                        kpt.psit_nG[:] = r.get('PseudoWaveFunctions', *indices)+                        r.get('PseudoWaveFunctions', *indices, out=kpt.psit_nG, parallel=True)                     else:                         # Read band by band to save memory                         for myn, psit_G in enumerate(kpt.psit_nG):@@ -683,7 +687,7 @@          timer.start('Projections')         for u, kpt in enumerate(wfs.kpt_u):-            P_ni = r.get('Projections', kpt.s, kpt.k)+            P_ni = r.get('Projections', kpt.s, kpt.k, **par_kwargs)             i1 = 0             kpt.P_ani = {}             for a, setup in enumerate(wfs.setups):@@ -710,7 +714,7 @@      # Get the forces from the old calculation:     if r.has_array('CartesianForces'):-        paw.forces.F_av = r.get('CartesianForces')+        paw.forces.F_av = r.get('CartesianForces', **par_kwargs)     else:         paw.forces.reset() @@ -719,14 +723,21 @@ def read_atoms(reader):     if isinstance(reader, str):         reader = open(filename, 'r')+        assert not hasattr(reader, 'hdf5_reader') #XXX needs a communicator! -    positions = reader.get('CartesianPositions') * Bohr-    numbers = reader.get('AtomicNumbers')-    cell = reader.get('UnitCell') * Bohr-    pbc = reader.get('BoundaryConditions')-    tags = reader.get('Tags')-    magmoms = reader.get('MagneticMoments')+    hdf5 = hasattr(reader, 'hdf5_reader') +    par_kwargs = {}+    if hdf5:+        par_kwargs.update({'parallel': True, 'read': True}) #XXX read on master only?++    positions = reader.get('CartesianPositions', **par_kwargs) * Bohr+    numbers = reader.get('AtomicNumbers', **par_kwargs)+    cell = reader.get('UnitCell', **par_kwargs) * Bohr+    pbc = reader.get('BoundaryConditions', **par_kwargs)+    tags = reader.get('Tags', **par_kwargs)+    magmoms = reader.get('MagneticMoments', **par_kwargs)+     atoms = Atoms(positions=positions,                   numbers=numbers,                   cell=cell,@@ -740,7 +751,13 @@     return atoms  def read_atomic_matrices(reader, key, setups):-    all_M_sp = reader.get(key)+    hdf5 = hasattr(reader, 'hdf5_reader')++    par_kwargs = {}+    if hdf5:+        par_kwargs.update({'parallel': True, 'read': True}) #XXX read on master only?++    all_M_sp = reader.get(key, **par_kwargs)     M_asp = {}     p1 = 0     for a, setup in enumerate(setups):Index: gpaw/io/hdf5.py===================================================================--- gpaw/io/hdf5.py	(revision 6958)+++ gpaw/io/hdf5.py	(working copy)@@ -173,6 +173,7 @@         # They cannot be placed after a variable-length argument indentifier.         parallel = kwargs.pop('parallel', False)         read = kwargs.pop('read', True)+        out = kwargs.pop('out', None)         assert not kwargs          if parallel:@@ -195,7 +196,13 @@         mshape = selection.mshape          # Create the output array using information from the selection.-        array = np.ndarray(mshape, new_dtype, order='C')+        if out is None:+            array = np.ndarray(mshape, new_dtype, order='C')+        else:+            assert type(out) is np.ndarray+            assert out.shape == mshape+            assert out.dtype == new_dtype+            array = out          # This is necessary because in the case of array types, NumPy         # discards the array information at the top level.