Skip to content

Commit 6486741

Browse files
committed
Fixed cell
1 parent 94c8661 commit 6486741

2 files changed

Lines changed: 23 additions & 5 deletions

File tree

Modules/Relax.py

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,12 @@ def __init__(self, minimizer = None, ase_calculator=None, N_configs=1, max_pop =
9898
self.target_pressure = 0
9999
self.fix_volume = False
100100

101+
# Options for the cell relaxation
102+
# If true the cell shape is fixed in a variable-cell relaxation
103+
# even if the symmetries allows for more degrees of freedom in the cell shape.
104+
# Usefull (for example) if you want to enfoce a cubic cell even if the structure brakes the symmetries
105+
self.fix_cell_shape = False
106+
101107

102108
# Setup the attribute control
103109
self.__total_attributes__ = [item for item in self.__dict__.keys()]
@@ -351,7 +357,10 @@ def vc_relax(self, target_press = 0, static_bulk_modulus = 100,
351357
This function performs a variable cell SCHA relaxation at constant pressure,
352358
It is similar to the relax calculation, but the unit cell is updated according
353359
to the anharmonic stress tensor at each new population.
354-
The cell optimization is performed with the BFGS algorithm.
360+
361+
By default, all the degrees of freedom compatible with the symmetry group are relaxed in the cell.
362+
You can constrain the cell to keep the same shape by setting fix_cell_shape = True.
363+
355364
356365
NOTE:
357366
remember to setup the stress_offset variable of the SCHA_Minimizer,
@@ -360,6 +369,7 @@ def vc_relax(self, target_press = 0, static_bulk_modulus = 100,
360369
stress tensor difference between a single very high-cutoff calculation and a
361370
single low-cutoff (the one you use), this difference will be added at the final
362371
stress tensor to get a better estimation of the true stress.
372+
363373
364374
Parameters
365375
----------
@@ -393,7 +403,8 @@ def vc_relax(self, target_press = 0, static_bulk_modulus = 100,
393403
does not support it by default)
394404
cell_relax_algorithm : string
395405
This identifies the stress algorithm. It can be both sd (steepest-descent),
396-
cg (conjugate-gradient) or bfgs (Quasi-newton)
406+
cg (conjugate-gradient) or bfgs (Quasi-newton).
407+
The most robust one is SD. Do not change if you are not sure what you are doing.
397408
fix_volume : bool, optional
398409
If true (default False) the volume is fixed, therefore only the cell shape is relaxed.
399410
@@ -558,7 +569,11 @@ def vc_relax(self, target_press = 0, static_bulk_modulus = 100,
558569
# print ""
559570

560571
# Perform the cell step
561-
cell_gradient = (stress_tensor - I *target_press_evA3)
572+
if self.fix_cell_shape:
573+
# Use a isotropic stress tensor to keep the same cell shape
574+
cell_gradient = I * (Press - target_press_evA3)
575+
else:
576+
cell_gradient = (stress_tensor - I *target_press_evA3)
562577

563578
new_uc = self.minim.dyn.structure.unit_cell.copy()
564579
BFGS.UpdateCell(new_uc, cell_gradient, fix_volume)

Modules/SchaMinimizer.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -481,8 +481,11 @@ def minimization_step(self, custom_function_gradient = None):
481481

482482
if diag_error_counter >= self.max_diag_error_counter:
483483
ERROR_MSG = """
484-
Error, exceeded the maximum number of diagonalization error.
485-
something is very wrong with the dynamical matrix.
484+
Error, exceeded the maximum number of diagonalization error. (or imaginary steps)
485+
486+
you can get rid of this error by increasing max_diag_error_counter variable.
487+
488+
Something is very wrong with the dynamical matrix.
486489
I'm saving the dynamical matrix as error_dyn,
487490
if you want to check it or restart the calculation from there.
488491
"""

0 commit comments

Comments
 (0)