Skip to content

Commit 3113b3e

Browse files
Set keys to define the Sobol sampling for the sscha inputfile. The new keys are "sobol_sampling"=(bool) and "sobol_scatter"=(float) in "&relax".
1 parent 53bbb5c commit 3113b3e

1 file changed

Lines changed: 23 additions & 5 deletions

File tree

Modules/Relax.py

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@
3232
__RELAX_TARGET_PRESSURE__ = "target_pressure"
3333
__RELAX_FIXVOLUME__ = "fix_volume"
3434
__RELAX_BULK_MODULUS__ = "bulk_modulus"
35+
__RELAX_SOBOL__ = "sobol_sampling"
36+
__RELAX_SOBOL_SCATTER__ = "sobol_scatter"
3537

3638
__TYPE_SINGLE__ = "sscha"
3739
__TYPE_RELAX__ = "relax"
@@ -42,7 +44,8 @@
4244
__ALLOWED_KEYS__ = [__RELAX_TYPE__, __RELAX_NCONFIGS__, __RELAX_MAX_POP__,
4345
__RELAX_START_POP__, __RELAX_SAVE_ENSEMBLE__,
4446
__RELAX_FIXVOLUME__, __RELAX_TARGET_PRESSURE__,
45-
__RELAX_BULK_MODULUS__, __RELAX_GENERATE_FIRST_ENSEMBLE__]
47+
__RELAX_BULK_MODULUS__, __RELAX_GENERATE_FIRST_ENSEMBLE__,
48+
__RELAX_SOBOL__, __RELAX_SOBOL_SCATTER__]
4649

4750
class SSCHA(object):
4851

@@ -106,6 +109,11 @@ def __init__(self, minimizer = None, ase_calculator=None, N_configs=1, max_pop =
106109
self.fix_cell_shape = False
107110

108111

112+
# Set the Sobol Parameters by default (aka no Sobol)
113+
self.sobol_sampling = False
114+
self.sobol_scatter = 0.0
115+
116+
109117
# Setup the attribute control
110118
self.__total_attributes__ = [item for item in self.__dict__.keys()]
111119
self.fixed_attributes = True # This must be the last attribute to be setted
@@ -115,6 +123,7 @@ def __init__(self, minimizer = None, ase_calculator=None, N_configs=1, max_pop =
115123
for key in kwargs:
116124
self.__setattr__(key, kwargs[key])
117125

126+
118127
def __setattr__(self, name, value):
119128
"""
120129
This method is used to set an attribute.
@@ -203,6 +212,12 @@ def setup_from_namelist(self, namelist):
203212
if __RELAX_FIXVOLUME__ in keys:
204213
self.fix_volume = bool(c_info[__RELAX_FIXVOLUME__])
205214

215+
# ****Diegom_test****
216+
if __RELAX_SOBOL__ in keys:
217+
self.sobol_sampling = bool(c_info[__RELAX_SOBOL__])
218+
219+
if __RELAX_SOBOL_SCATTER__ in keys:
220+
self.sobol_scatter = np.float64(c_info[__RELAX_SOBOL_SCATTER__])
206221

207222
# Check the allowed keys
208223
for k in keys:
@@ -238,10 +253,11 @@ def setup_from_namelist(self, namelist):
238253

239254
if rtype == __TYPE_RELAX__:
240255
self.relax(restart_from_ens, self.minim.ensemble.has_stress, self.data_dir,
241-
self.start_pop)
256+
self.start_pop, sobol = self.sobol_sampling, sobol_scatter = self.sobol_scatter)
242257
elif rtype == __TYPE_VCRELAX__:
243258
self.vc_relax(self.target_pressure, self.bulk_modulus,
244-
restart_from_ens, self.data_dir, self.start_pop, fix_volume=self.fix_volume)
259+
restart_from_ens, self.data_dir, self.start_pop, fix_volume=self.fix_volume,
260+
sobol = self.sobol_sampling, sobol_scatter = self.sobol_scatter)
245261

246262
def setup_custom_functions(self, custom_function_pre = None,
247263
custom_function_gradient = None,
@@ -257,7 +273,8 @@ def setup_custom_functions(self, custom_function_pre = None,
257273

258274

259275
def relax(self, restart_from_ens = False, get_stress = False,
260-
ensemble_loc = None, start_pop = None, sobol = False, sobol_scramble = False, sobol_scatter = 0.0):
276+
ensemble_loc = None, start_pop = None, sobol = False,
277+
sobol_scramble = False, sobol_scatter = 0.0):
261278
"""
262279
COSTANT VOLUME RELAX
263280
====================
@@ -382,7 +399,8 @@ def relax(self, restart_from_ens = False, get_stress = False,
382399
def vc_relax(self, target_press = 0, static_bulk_modulus = 100,
383400
restart_from_ens = False,
384401
ensemble_loc = None, start_pop = None, stress_numerical = False,
385-
cell_relax_algorithm = "sd", fix_volume = False, sobol = False, sobol_scramble = False, sobol_scatter = 0.0):
402+
cell_relax_algorithm = "sd", fix_volume = False, sobol = False,
403+
sobol_scramble = False, sobol_scatter = 0.0):
386404
"""
387405
VARIABLE CELL RELAX
388406
====================

0 commit comments

Comments
 (0)