diff --git a/other/materials_designer/create_interface_with_relaxation_ase_emt.ipynb b/other/materials_designer/create_interface_with_relaxation_ase_emt.ipynb index c0eab3f6..5c435310 100644 --- a/other/materials_designer/create_interface_with_relaxation_ase_emt.ipynb +++ b/other/materials_designer/create_interface_with_relaxation_ase_emt.ipynb @@ -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", @@ -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]" ] }, { @@ -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, @@ -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", @@ -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",