Skip to content

Commit d25e950

Browse files
committed
Added an example for vc_relax without automatic submission. Also added a fix to restart from ensemble without passing start_pop in the vc_relax mode
1 parent 345c5fe commit d25e950

3 files changed

Lines changed: 36 additions & 4 deletions

File tree

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import cellconstructor as CC, cellconstructor.Phonons
2+
import sscha, sscha.Ensemble, sscha.SchaMinimizer, sscha.Utilities
3+
import sscha.Relax
4+
5+
6+
# Load the dynamical matrix
7+
dyn = CC.Phonons.Phonons("../ensemble_data_test/dyn", nqirr=1)
8+
9+
# Load the ensemble (0 K)
10+
ensemble = sscha.Ensemble.Ensemble(dyn, T0=0)
11+
ensemble.load("../ensemble_data_test/", population=2, N=1000)
12+
13+
# Prepare the minimization
14+
minim = sscha.SchaMinimizer.SSCHA_Minimizer(ensemble)
15+
16+
# Prepare the auxiliary functions to save the minimization output
17+
ioinfo = sscha.Utilities.IOInfo()
18+
ioinfo.SetupSaving("minim_1")
19+
20+
# Prepare the vc-relax
21+
relax = sscha.Relax.SSCHA(minim, max_pop=1)
22+
relax.setup_custom_functions(custom_function_post=ioinfo.CFP_SaveAll)
23+
24+
# Run the vc-relax
25+
relax.vc_relax(target_press=0, static_bulk_modulus=100,
26+
restart_from_ens=True)
27+
28+
# Save the final dynamical matrix
29+
relax.minim.dyn.save_qe("final_dyn")

Modules/Ensemble.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -86,12 +86,12 @@
8686
except:
8787
try:
8888
import julia
89-
from julia.api import Julia
90-
jl = Julia(compiled_modules=False)
91-
import julia.Main
9289
try:
90+
from julia.api import Julia
91+
jl = Julia(compiled_modules=False)
92+
import julia.Main
9393
julia.Main.include(os.path.join(os.path.dirname(__file__),
94-
"fourier_gradient.jl"))
94+
"fourier_gradient.jl"))
9595
__JULIA_EXT__ = True
9696
except:
9797
# Install the required modules

Modules/Relax.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -576,6 +576,7 @@ def vc_relax(self, target_press = 0, static_bulk_modulus = 100,
576576
pop = start_pop
577577
else:
578578
pop = self.start_pop
579+
start_pop = self.start_pop
579580

580581
running = True
581582
while running:
@@ -590,6 +591,8 @@ def vc_relax(self, target_press = 0, static_bulk_modulus = 100,
590591
# Generate the ensemble
591592
self.minim.ensemble.dyn_0 = self.minim.dyn.Copy()
592593
if pop != start_pop or not restart_from_ens:
594+
print("POP:", pop, "START_POP:", start_pop)
595+
print("RESTART_FROM_ENS:", restart_from_ens)
593596
self.minim.ensemble.generate(self.N_configs, sobol=sobol, sobol_scramble = sobol_scramble, sobol_scatter = sobol_scatter)
594597

595598
# Save also the generation

0 commit comments

Comments
 (0)