Skip to content

Commit 9efb152

Browse files
Merge pull request #111 from SSCHAcode/fast_parallel_gradient
Fast parallelization of gradient calculation
2 parents 1ec3aff + a40295b commit 9efb152

9 files changed

Lines changed: 1588 additions & 196 deletions

File tree

Modules/Ensemble.py

Lines changed: 265 additions & 135 deletions
Large diffs are not rendered by default.

Modules/Relax.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -576,15 +576,20 @@ def vc_relax(self, target_press = 0, static_bulk_modulus = 100,
576576
cluster = self.cluster)
577577
#self.minim.ensemble.get_energy_forces(self.calc, True, stress_numerical = stress_numerical)
578578

579+
print("RELAX force length:", len(self.minim.ensemble.force_computed))
580+
579581
if ensemble_loc is not None and self.save_ensemble:
580582
self.minim.ensemble.save_bin(ensemble_loc, pop)
583+
print("RELAX force length:", len(self.minim.ensemble.force_computed))
581584

582585
self.minim.population = pop
583586
self.minim.init(delete_previous_data = False)
584587

588+
print("RELAX force length:", len(self.minim.ensemble.force_computed))
585589
self.minim.run(custom_function_pre = self.__cfpre__,
586590
custom_function_post = self.__cfpost__,
587591
custom_function_gradient = self.__cfg__)
592+
588593

589594

590595
self.minim.finalize()

Modules/SchaMinimizer.py

Lines changed: 174 additions & 49 deletions
Large diffs are not rendered by default.

SCHAModules/get_gradient_supercell.f90

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -395,7 +395,7 @@ subroutine get_gradient_supercell_new( n_random, natsc, n_modes, ntyp_sc, rho, u
395395
!print *, "Time to compute the upsilon matrix:", t2 - t1
396396

397397

398-
!$OMP PARALLEL DO PRIVATE(ical, jcal)
398+
!!$OMP PARALLEL DO PRIVATE(ical, jcal)
399399
do i_r = 1, n_random
400400
do alpha = 1, 3
401401
do i = 1, natsc
@@ -412,11 +412,11 @@ subroutine get_gradient_supercell_new( n_random, natsc, n_modes, ntyp_sc, rho, u
412412
enddo
413413
enddo
414414
enddo
415-
!$OMP END PARALLEL DO
415+
!!$OMP END PARALLEL DO
416416

417417

418418
call cpu_time(t1)
419-
!$OMP PARALLEL DO COLLAPSE(4) PRIVATE(ical, jcal)
419+
!!$OMP PARALLEL DO COLLAPSE(4) PRIVATE(ical, jcal)
420420
do alpha = 1, 3
421421
do beta = 1, 3
422422
do i = 1, natsc
@@ -431,7 +431,7 @@ subroutine get_gradient_supercell_new( n_random, natsc, n_modes, ntyp_sc, rho, u
431431
end do
432432
end do
433433
end do
434-
!$OMP END PARALLEL DO
434+
!!$OMP END PARALLEL DO
435435

436436
! Impose the hermitianity
437437
! do ical = 1, 3*natsc

UserGuide/start.rst

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,8 @@ You find a copy of the script and the cif file of Gold inside the directory Exam
5656
relax = CC.calculators.Relax(gold_structure, calculator)
5757
gold_structure_relaxed = relax.static_relax()
5858
59-
# Compute the harmonic phonons
59+
# Compute the harmonic phonons
60+
# (as from version 1.3 of Cellconstructor, it will exploit the symmetries as phonopy to reduce the number of displacements)
6061
# NOTE: if the code is run with mpirun, the calculation goes in parallel
6162
gold_harmonic_dyn = CC.Phonons.compute_phonons_finite_displacements(gold_structure_relaxed, calculator, supercell = (4,4,4))
6263
@@ -212,8 +213,8 @@ You can use it even in your simulation, simply edit the value of the uppercase k
212213
# --------------------- THE SCRIPT FOLLOWS ---------------------
213214
214215
# Load the harmonic and sscha phonons
215-
harmonic_dyn = CC.Phonons.Phonons(, NQIRR)
216-
sscha_dyn = CC.Phonons.Phonons('sscha_T300_dyn', NQIRR)
216+
harmonic_dyn = CC.Phonons.Phonons(HARM_DYN, NQIRR)
217+
sscha_dyn = CC.Phonons.Phonons(SSCHA_DYN, NQIRR)
217218
218219
# Get the band path
219220
qpath, data = CC.Methods.get_bandpath(harmonic_dyn.structure.unit_cell,
@@ -322,8 +323,9 @@ In the next part of the code, we perform the harmonic phonon calculation using c
322323
323324
324325
The method `compute_phonons_finite_displacements` is documented in the CellConstructor guide. It requires the structure (in this case `gold_structure_relaxed`), the force-field (`calculator`) and the supercell for the calculation. In this case we use a 4x4x4 (equivalent to 64 atoms). This may not be sufficient to converge all the properties, especially at very high temperature, but it is just a start.
325-
326-
Note that `compute_phonons_finite_displacements` works in parallel with MPI, therefore, if the script is executed with `mpirun -np 16 python myscript.py` it will split the calculations of the finite displacements across 16 processors. You need to have mpi4py installed.
326+
Starting from version 1.3 of Cellconstructor, this automatically exploits the symmetry of the structure to reduce the number of displacements to compute.
327+
This is extremely efficient for big supercells.
328+
Note that `compute_phonons_finite_displacements` works in parallel with MPI, therefore, if the script is executed with `mpirun -np 4 python myscript.py` it will split the calculations of the finite displacements across 4 processors. You need to have mpi4py installed.
327329

328330
After computing the harmonic phonons in gold_harmonic_dyn, we impose the correct symmetrization and the acousitic sum rule with the `Symmetrize` method, and save the result in the quantum ESPRESSO format with `save_qe`.
329331
This should not be the case for Gold, however, if we have a structure which has imaginary phonon frequencies, we need to get rid of them before starting the SSCHA. This is achieved with `ForcePositiveDefinite` (see CellConstructor documentation for more details on how these methods work).
@@ -850,14 +852,14 @@ First of all, we need to configure a straight ssh connection. We have to add to
850852
851853
Host ela
852854
HostName ela.cscs.ch
853-
User lmonacel
855+
User myusernameforela
854856
Host daint
855857
HostName daint.cscs.ch
856858
ProxyJump ela
857-
User lmonacel
859+
User myusernamefordaint
858860
859861
860-
These are two connection, one to ela (the front-end server of CSCS) and then one to daint.
862+
These are two connection, one to ela (the front-end server of CSCS) and then one to daint (Piz Daint supercomputer).
861863
To connect to daint, I must before access to ela, this is the reason of ProxyJump command inside the daint block.
862864
The best way to connect is to configure your ssh private-public key so that you (and python-sscha) can login without password.
863865
An example of how to do that is `Here <http://www.linuxproblem.org/art_9.html>`_, but you may find a lot of other on internet.

setup.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
mpi_compile_args = []
1010
mpi_link_args = []
1111

12+
1213
# If true, do not check for parallel
1314
avoid_parallel_test = True
1415

0 commit comments

Comments
 (0)