Skip to content

Commit

Permalink
update: use relaxation from made-tools
Browse files Browse the repository at this point in the history
  • Loading branch information
VsevolodX committed May 11, 2024
1 parent e15bd4a commit 877d402
Showing 1 changed file with 51 additions and 6 deletions.
Expand Up @@ -97,11 +97,19 @@
"source": [
"RELAXATION_PARAMETERS = {\n",
" \"FMAX\": 0.018,\n",
"}"
"}\n",
"\n",
"from mat3ra.made.tools.modify import RelaxationSettings, CalculatorEnum, OptimizerEnum\n",
"relaxation_settings = RelaxationSettings()\n",
"\n",
"relaxation_settings.optimizer = OptimizerEnum.BFGS\n",
"relaxation_settings.calculator = CalculatorEnum.EMT\n",
"relaxation_settings.fmax = 0.05"
],
"metadata": {
"collapsed": false
}
},
"execution_count": null
},
{
"cell_type": "markdown",
Expand Down Expand Up @@ -303,7 +311,7 @@
"termination_or_its_index = selected_termination\n",
"# select the first interface with the lowest strain and the smallest number of atoms\n",
"interfaces_slice_range_or_index = 0\n",
"interface = interface_data_holder.get_interfaces_as_materials(termination_or_its_index, interfaces_slice_range_or_index)"
"interface = interface_data_holder.get_interfaces_as_materials(termination_or_its_index, interfaces_slice_range_or_index)[0]"
]
},
{
Expand Down Expand Up @@ -341,6 +349,29 @@
"### 7.1. Apply relaxation to the selected interface"
]
},
{
"cell_type": "code",
"outputs": [],
"source": [
"from utils.plot import create_realtime_plot, update_plot\n",
"\n",
"from mat3ra.made.tools.modify import relax_atoms\n",
"from mat3ra.made.tools.convert import to_ase\n",
"\n",
"final_interface = relax_atoms(Material(interface), relaxation_settings)\n",
"\n",
"f = create_realtime_plot()\n",
"steps = []\n",
"energies = []\n",
"update_plot(f, steps, energies)\n",
"\n",
"visualize(final_interface, repetitions=[1, 1, 1], rotation=\"0x\")"
],
"metadata": {
"collapsed": false
},
"execution_count": null
},
{
"cell_type": "code",
"execution_count": null,
Expand All @@ -354,14 +385,24 @@
"from ase.optimize import BFGS\n",
"from ase.calculators.emt import EMT\n",
"\n",
"\n",
"# Set up the calculator \n",
"calculator = EMT()\n",
"print(calculator)\n",
"\n",
"# Set up the interface for relaxation\n",
"ase_interface = pymatgen_to_ase(interface)\n",
"ase_interface = to_ase(interface)\n",
"print(ase_interface)\n",
"ase_interface.set_calculator(calculator)\n",
"print(ase_interface)\n",
"dyn = BFGS(ase_interface)\n",
"\n",
"\n"
]
},
{
"cell_type": "code",
"outputs": [],
"source": [
"# Initialize empty lists to store steps and energies\n",
"steps = []\n",
"energies = []\n",
Expand Down Expand Up @@ -410,7 +451,11 @@
"print('Original structure:\\n', ase_to_poscar(ase_original_interface))\n",
"print('\\nRelaxed structure:\\n', ase_to_poscar(ase_final_interface))\n",
"print(f\"The final energy is {float(relaxed_energy):.3f} eV.\")"
]
],
"metadata": {
"collapsed": false
},
"execution_count": null
},
{
"cell_type": "markdown",
Expand Down

0 comments on commit 877d402

Please sign in to comment.