diff --git a/docs/source/conf.py b/docs/source/conf.py index 34bc9cd..bf93ff0 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -20,8 +20,8 @@ # -- Project information ----------------------------------------------------- -project = "WorkGraph Collections" -copyright = "2023, Xing Wang" +project = "ASE QuantumESPRESSO" +copyright = "2024, Xing Wang" author = "Xing Wang" # The full version, including alpha/beta/rc tags diff --git a/docs/source/installation.rst b/docs/source/installation.rst index 78c6cfb..d5b2339 100644 --- a/docs/source/installation.rst +++ b/docs/source/installation.rst @@ -7,7 +7,7 @@ The recommended method of installation is to use the Python package manager |pip .. code-block:: console - $ pip install git+https://github.com/superstar54/workgraph-collections.git + $ pip install ase-quantumespresso This will install the latest version. diff --git a/docs/source/quickstart.ipynb b/docs/source/quickstart.ipynb index a8157b1..7e119f7 100644 --- a/docs/source/quickstart.ipynb +++ b/docs/source/quickstart.ipynb @@ -13,18 +13,22 @@ }, { "cell_type": "code", - "execution_count": 10, + "execution_count": 2, "metadata": {}, "outputs": [ { - "data": { - "text/plain": [ - "-278.0726613506829" - ] - }, - "execution_count": 10, - "metadata": {}, - "output_type": "execute_result" + "name": "stderr", + "output_type": "stream", + "text": [ + "INFO:xmlschema:Resource 'XMLSchema.xsd' is already loaded\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "energy: -278.0726613506829\n" + ] } ], "source": [ @@ -51,161 +55,43 @@ " profile=profile,\n", " pseudopotentials=pseudopotentials,\n", " input_data=input_data,\n", - " directory=\"test\",\n", + " directory=\"calculation\",\n", " kpts=[8, 8, 8],\n", ")\n", "atoms.calc = calc\n", - "atoms.get_potential_energy()" + "energy = atoms.get_potential_energy()\n", + "print(\"energy:\", energy)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ - "Here is the results:" + "Here are the results of the calculation:" ] }, { "cell_type": "code", - "execution_count": 11, + "execution_count": 4, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ - "results:\n", - "output_band {'bands': {'energies': array([[-5.7582147 , 6.21029835, 6.21029857, 6.21029903, 8.77617461,\n", - " 8.77618558, 8.77618696, 9.56732039],\n", - " [-5.55405334, 4.60892119, 5.92074171, 5.92074218, 8.71320273,\n", - " 9.20163357, 9.2016577 , 10.91639464],\n", - " [-4.95839291, 2.27860376, 5.44808179, 5.44808253, 8.24042894,\n", - " 9.72220395, 9.72221687, 13.12458414],\n", - " [-4.0643594 , 0.25688813, 5.11972177, 5.11972195, 7.8770698 ,\n", - " 9.66911303, 9.66922072, 14.09264244],\n", - " [-3.42597226, -0.76637666, 5.00760458, 5.00760548, 7.74974373,\n", - " 9.5585018 , 9.55852328, 13.93942198],\n", - " [-5.4852536 , 4.87517624, 5.40159313, 5.40159367, 8.22466469,\n", - " 9.91880897, 9.91883444, 10.60308052],\n", - " [-5.01652832, 2.98216181, 4.8885215 , 4.965073 , 8.36176225,\n", - " 9.91972719, 10.68531957, 10.9729757 ],\n", - " [-4.20136989, 0.91985933, 4.37278236, 4.61974963, 8.46216379,\n", - " 9.85666955, 10.68568426, 11.69095393],\n", - " [-3.3394378 , -0.54466015, 3.92638084, 4.64376573, 8.40845154,\n", - " 9.73176832, 10.32160447, 13.59096494],\n", - " [-3.58416699, -0.1737059 , 3.74446611, 4.94085492, 8.57438069,\n", - " 9.84167173, 10.08822286, 14.1306794 ],\n", - " [-4.50777564, 1.57956889, 3.8955226 , 5.43363562, 8.93200641,\n", - " 9.8938822 , 10.07578337, 12.51406659],\n", - " [-5.21780758, 3.52277758, 4.57857648, 5.91622452, 9.25412368,\n", - " 9.33782132, 9.57618096, 11.76150861],\n", - " [-4.67609662, 2.68977109, 4.31632177, 4.31632186, 7.34395788,\n", - " 9.35278224, 11.97755398, 11.97757572],\n", - " [-3.96594354, 1.26463276, 3.5349381 , 3.99731861, 7.56513858,\n", - " 9.11275911, 12.21582716, 12.49211157],\n", - " [-3.0395261 , -0.17837819, 2.67102931, 4.00019606, 7.73543535,\n", - " 10.66904422, 11.9610814 , 12.14374851],\n", - " [-2.83506542, -0.43701251, 2.21210221, 4.31914958, 8.06031271,\n", - " 11.68663156, 11.70157761, 13.1801353 ],\n", - " [-3.71401103, 0.72456785, 2.45227707, 4.87859385, 8.66548342,\n", - " 11.00607546, 11.35552754, 12.35736989],\n", - " [-3.36332216, 0.45979531, 3.59799438, 3.59799444, 6.82886801,\n", - " 7.75703924, 14.26239177, 14.26240117],\n", - " [-2.46570063, -0.62580988, 2.768904 , 3.52166123, 7.10991283,\n", - " 8.18435176, 14.49029386, 14.57392774],\n", - " [-2.02655839, -1.02265487, 1.90264243, 3.77964349, 7.41943233,\n", - " 10.34849617, 13.68818157, 14.24212325],\n", - " [-1.61282116, -1.61282096, 3.35192357, 3.35192381, 6.92567976,\n", - " 6.92568062, 16.31907784, 16.31909948],\n", - " [-4.42860586, 1.91621092, 3.49269407, 4.77909638, 8.66225693,\n", - " 10.11572206, 10.41630452, 11.72137335],\n", - " [-3.54000429, 0.36308126, 2.88436735, 4.27680809, 9.09393775,\n", - " 9.77195011, 11.23874215, 12.15987666],\n", - " [-2.88722115, -0.58271573, 2.75546728, 4.04670191, 9.28298835,\n", - " 9.35098401, 12.13291672, 13.34562402],\n", - " [-3.16461316, 0.24060349, 2.84268849, 3.44604408, 8.16215526,\n", - " 8.86467323, 11.97354864, 14.2125503 ],\n", - " [-2.28939419, -0.72785999, 2.14424429, 3.24518418, 8.60520294,\n", - " 10.50204672, 11.49472356, 13.66031456],\n", - " [-2.64013208, -0.36446604, 1.97729554, 3.62158383, 9.08534096,\n", - " 10.76395069, 11.43428359, 13.25359708],\n", - " [-1.53477173, -1.53477168, 2.78803297, 2.78803339, 8.18744617,\n", - " 8.18750588, 14.0686654 , 14.0686833 ],\n", - " [-1.44875405, -1.44875383, 2.35214219, 2.3521424 , 10.49231616,\n", - " 10.49232524, 11.21859407, 11.21860183]]), 'units': 'eV', 'occupations': array([[2.00000000e+00, 1.99814740e+00, 1.99814739e+00, 1.99814736e+00,\n", - " 0.00000000e+00, 0.00000000e+00, 0.00000000e+00, 0.00000000e+00],\n", - " [2.00000000e+00, 2.00000000e+00, 2.00000000e+00, 2.00000000e+00,\n", - " 0.00000000e+00, 0.00000000e+00, 0.00000000e+00, 0.00000000e+00],\n", - " [2.00000000e+00, 2.00000000e+00, 2.00000000e+00, 2.00000000e+00,\n", - " 2.38270390e-72, 0.00000000e+00, 0.00000000e+00, 0.00000000e+00],\n", - " [2.00000000e+00, 2.00000000e+00, 2.00000000e+00, 2.00000000e+00,\n", - " 7.72010887e-46, 0.00000000e+00, 0.00000000e+00, 0.00000000e+00],\n", - " [2.00000000e+00, 2.00000000e+00, 2.00000000e+00, 2.00000000e+00,\n", - " 5.22322824e-38, 0.00000000e+00, 0.00000000e+00, 0.00000000e+00],\n", - " [2.00000000e+00, 2.00000000e+00, 2.00000000e+00, 2.00000000e+00,\n", - " 4.52192415e-71, 0.00000000e+00, 0.00000000e+00, 0.00000000e+00],\n", - " [2.00000000e+00, 2.00000000e+00, 2.00000000e+00, 2.00000000e+00,\n", - " 1.41114730e-82, 0.00000000e+00, 0.00000000e+00, 0.00000000e+00],\n", - " [2.00000000e+00, 2.00000000e+00, 2.00000000e+00, 2.00000000e+00,\n", - " 0.00000000e+00, 0.00000000e+00, 0.00000000e+00, 0.00000000e+00],\n", - " [2.00000000e+00, 2.00000000e+00, 2.00000000e+00, 2.00000000e+00,\n", - " 1.07267243e-86, 0.00000000e+00, 0.00000000e+00, 0.00000000e+00],\n", - " [2.00000000e+00, 2.00000000e+00, 2.00000000e+00, 2.00000000e+00,\n", - " 0.00000000e+00, 0.00000000e+00, 0.00000000e+00, 0.00000000e+00],\n", - " [2.00000000e+00, 2.00000000e+00, 2.00000000e+00, 2.00000000e+00,\n", - " 0.00000000e+00, 0.00000000e+00, 0.00000000e+00, 0.00000000e+00],\n", - " [2.00000000e+00, 2.00000000e+00, 2.00000000e+00, 2.00000000e+00,\n", - " 0.00000000e+00, 0.00000000e+00, 0.00000000e+00, 0.00000000e+00],\n", - " [2.00000000e+00, 2.00000000e+00, 2.00000000e+00, 2.00000000e+00,\n", - " 4.29565684e-18, 0.00000000e+00, 0.00000000e+00, 0.00000000e+00],\n", - " [2.00000000e+00, 2.00000000e+00, 2.00000000e+00, 2.00000000e+00,\n", - " 5.34559567e-28, 0.00000000e+00, 0.00000000e+00, 0.00000000e+00],\n", - " [2.00000000e+00, 2.00000000e+00, 2.00000000e+00, 2.00000000e+00,\n", - " 3.55298972e-37, 0.00000000e+00, 0.00000000e+00, 0.00000000e+00],\n", - " [2.00000000e+00, 2.00000000e+00, 2.00000000e+00, 2.00000000e+00,\n", - " 1.94837712e-58, 0.00000000e+00, 0.00000000e+00, 0.00000000e+00],\n", - " [2.00000000e+00, 2.00000000e+00, 2.00000000e+00, 2.00000000e+00,\n", - " 0.00000000e+00, 0.00000000e+00, 0.00000000e+00, 0.00000000e+00],\n", - " [2.00000000e+00, 2.00000000e+00, 2.00000000e+00, 2.00000000e+00,\n", - " 9.10915053e-04, 1.94854924e-38, 0.00000000e+00, 0.00000000e+00],\n", - " [2.00000000e+00, 2.00000000e+00, 2.00000000e+00, 2.00000000e+00,\n", - " 4.43354761e-10, 7.43444436e-68, 0.00000000e+00, 0.00000000e+00],\n", - " [2.00000000e+00, 2.00000000e+00, 2.00000000e+00, 2.00000000e+00,\n", - " 3.22474111e-21, 0.00000000e+00, 0.00000000e+00, 0.00000000e+00],\n", - " [2.00000000e+00, 2.00000000e+00, 2.00000000e+00, 2.00000000e+00,\n", - " 1.53938721e-05, 1.53932531e-05, 0.00000000e+00, 0.00000000e+00],\n", - " [2.00000000e+00, 2.00000000e+00, 2.00000000e+00, 2.00000000e+00,\n", - " 0.00000000e+00, 0.00000000e+00, 0.00000000e+00, 0.00000000e+00],\n", - " [2.00000000e+00, 2.00000000e+00, 2.00000000e+00, 2.00000000e+00,\n", - " 0.00000000e+00, 0.00000000e+00, 0.00000000e+00, 0.00000000e+00],\n", - " [2.00000000e+00, 2.00000000e+00, 2.00000000e+00, 2.00000000e+00,\n", - " 0.00000000e+00, 0.00000000e+00, 0.00000000e+00, 0.00000000e+00],\n", - " [2.00000000e+00, 2.00000000e+00, 2.00000000e+00, 2.00000000e+00,\n", - " 4.06917443e-66, 0.00000000e+00, 0.00000000e+00, 0.00000000e+00],\n", - " [2.00000000e+00, 2.00000000e+00, 2.00000000e+00, 2.00000000e+00,\n", - " 0.00000000e+00, 0.00000000e+00, 0.00000000e+00, 0.00000000e+00],\n", - " [2.00000000e+00, 2.00000000e+00, 2.00000000e+00, 2.00000000e+00,\n", - " 0.00000000e+00, 0.00000000e+00, 0.00000000e+00, 0.00000000e+00],\n", - " [2.00000000e+00, 2.00000000e+00, 2.00000000e+00, 2.00000000e+00,\n", - " 4.23729204e-68, 4.19153080e-68, 0.00000000e+00, 0.00000000e+00],\n", - " [2.00000000e+00, 2.00000000e+00, 2.00000000e+00, 2.00000000e+00,\n", - " 0.00000000e+00, 0.00000000e+00, 0.00000000e+00, 0.00000000e+00]])}}\n", - "output_trajectory TrajectoryData(steps=array([0]), cells=array([[[0. , 2.715, 2.715],\n", - " [2.715, 0. , 2.715],\n", - " [2.715, 2.715, 0. ]]]), symbols=['Si', 'Si'], positions=array([[[0. , 0. , 0. ],\n", - " [1.3575, 1.3575, 1.3575]]]), arrays={'atomic_species_name': array(['Si', 'Si'], dtype='" + "" ] }, - "execution_count": 13, + "execution_count": 7, "metadata": {}, "output_type": "execute_result" }, @@ -294,13 +154,9 @@ "source": [ "import matplotlib.pyplot as plt\n", "\n", - "#------------------------- Print the output -------------------------\n", "dos_data = calc.results[\"dos\"]\n", - "print(dos_data.keys())\n", - "# make plots\n", "plt.figure(figsize = (8, 4))\n", "plt.plot(dos_data['x'][\"array\"], dos_data['y'][\"arrays\"][1], label='total')\n", - "# plt.plot(pdos_data['totol']['energy'], pdos_data['totol']['dos'], label='total')\n", "plt.yticks([])\n", "plt.xlabel('Energy (eV)')\n", "plt.ylabel('DOS')\n", @@ -316,250 +172,15 @@ }, { "cell_type": "code", - "execution_count": 14, + "execution_count": 1, "metadata": {}, "outputs": [ { - "name": "stdout", + "name": "stderr", "output_type": "stream", "text": [ - "results: dict_keys(['output_parameters', 'projections', 'bands', 'dos'])\n", - "results: dict_keys(['output_parameters', 'projections', 'bands', 'dos', 'exit_code'])\n" + "INFO:xmlschema:Resource 'XMLSchema.xsd' is already loaded\n" ] - }, - { - "data": { - "text/plain": [ - "ProjectionData(orbitals=[, , , , , , , ], list_of_projections=[array([[0.498, 0. , 0. , 0. , 0. , 0. , 0. , 0.494],\n", - " [0.45 , 0.088, 0. , 0. , 0.16 , 0. , 0. , 0.29 ],\n", - " [0.383, 0.142, 0. , 0. , 0.265, 0. , 0. , 0.179],\n", - " [0.362, 0.148, 0. , 0. , 0.321, 0. , 0. , 0.035],\n", - " [0.386, 0.119, 0. , 0. , 0.34 , 0. , 0. , 0.019],\n", - " [0.437, 0.133, 0. , 0. , 0.058, 0. , 0. , 0.325],\n", - " [0.382, 0.151, 0. , 0.048, 0.084, 0.141, 0. , 0.056],\n", - " [0.35 , 0.165, 0.063, 0. , 0.145, 0.09 , 0. , 0.067],\n", - " [0.366, 0.142, 0.064, 0. , 0.183, 0.077, 0. , 0.052],\n", - " [0.356, 0.153, 0.059, 0. , 0.2 , 0.057, 0. , 0.071],\n", - " [0.358, 0.163, 0.05 , 0. , 0.187, 0. , 0.04 , 0.119],\n", - " [0.402, 0.138, 0.028, 0. , 0.149, 0. , 0.06 , 0.17 ],\n", - " [0.354, 0.215, 0. , 0. , 0.135, 0.125, 0. , 0. ],\n", - " [0.328, 0.226, 0.029, 0. , 0.13 , 0.119, 0.053, 0. ],\n", - " [0.328, 0.215, 0.042, 0. , 0.126, 0.079, 0.109, 0. ],\n", - " [0.341, 0.201, 0.04 , 0. , 0.112, 0.086, 0. , 0.072],\n", - " [0.336, 0.21 , 0.037, 0. , 0.103, 0. , 0.077, 0.151],\n", - " [0.308, 0.256, 0. , 0. , 0.169, 0.146, 0. , 0. ],\n", - " [0.298, 0.272, 0.009, 0. , 0.156, 0.136, 0. , 0.038],\n", - " [0.324, 0.258, 0. , 0. , 0.135, 0.091, 0. , 0.057],\n", - " [0.282, 0.282, 0. , 0. , 0.17 , 0.17 , 0. , 0. ],\n", - " [0.348, 0.197, 0.035, 0.011, 0.081, 0.179, 0. , 0.016],\n", - " [0.334, 0.199, 0.054, 0.006, 0.1 , 0.063, 0.095, 0.029],\n", - " [0.351, 0.175, 0.063, 0.002, 0.163, 0.013, 0.042, 0.026],\n", - " [0.313, 0.257, 0.023, 0. , 0.118, 0.117, 0.052, 0.008],\n", - " [0.319, 0.26 , 0.013, 0.004, 0.101, 0.059, 0.095, 0.057],\n", - " [0.324, 0.25 , 0.014, 0.006, 0.075, 0.047, 0.103, 0.06 ],\n", - " [0.29 , 0.29 , 0.007, 0.007, 0.128, 0.129, 0.036, 0.036],\n", - " [0.3 , 0.3 , 0. , 0. , 0. , 0. , 0.158, 0.158]]), array([[0. , 0.16 , 0.16 , 0.16 , 0.161, 0.161, 0.161, 0. ],\n", - " [0.016, 0.133, 0.162, 0.162, 0.107, 0.159, 0.159, 0.064],\n", - " [0.038, 0.117, 0.163, 0.163, 0.069, 0.148, 0.148, 0.088],\n", - " [0.045, 0.115, 0.164, 0.164, 0.048, 0.132, 0.132, 0.036],\n", - " [0.037, 0.125, 0.165, 0.165, 0.04 , 0.128, 0.128, 0.022],\n", - " [0.02 , 0.118, 0.163, 0.163, 0.141, 0.156, 0.156, 0.044],\n", - " [0.038, 0.114, 0.164, 0.148, 0.128, 0.11 , 0.148, 0.053],\n", - " [0.049, 0.11 , 0.144, 0.165, 0.097, 0.112, 0.131, 0.048],\n", - " [0.044, 0.118, 0.144, 0.165, 0.083, 0.104, 0.124, 0.048],\n", - " [0.047, 0.114, 0.145, 0.165, 0.08 , 0.107, 0.127, 0.056],\n", - " [0.047, 0.111, 0.148, 0.164, 0.09 , 0.147, 0.12 , 0.063],\n", - " [0.032, 0.118, 0.154, 0.163, 0.109, 0.159, 0.131, 0.074],\n", - " [0.048, 0.093, 0.165, 0.165, 0.113, 0.043, 0.144, 0.144],\n", - " [0.056, 0.089, 0.156, 0.165, 0.106, 0.055, 0.113, 0.126],\n", - " [0.057, 0.093, 0.151, 0.165, 0.096, 0.057, 0.095, 0.114],\n", - " [0.053, 0.098, 0.152, 0.165, 0.1 , 0.061, 0.123, 0.053],\n", - " [0.054, 0.095, 0.153, 0.165, 0.106, 0.151, 0.082, 0.067],\n", - " [0.063, 0.08 , 0.166, 0.166, 0.096, 0.062, 0.126, 0.126],\n", - " [0.066, 0.075, 0.163, 0.166, 0.089, 0.078, 0.108, 0.093],\n", - " [0.058, 0.08 , 0.166, 0.166, 0.094, 0.063, 0.137, 0.036],\n", - " [0.072, 0.072, 0.166, 0.166, 0.082, 0.082, 0.154, 0.154],\n", - " [0.05 , 0.099, 0.153, 0.161, 0.126, 0.072, 0.085, 0.134],\n", - " [0.055, 0.099, 0.147, 0.163, 0.102, 0.108, 0.062, 0.102],\n", - " [0.049, 0.107, 0.144, 0.164, 0.086, 0.114, 0.099, 0.024],\n", - " [0.062, 0.08 , 0.158, 0.165, 0.106, 0.062, 0.104, 0.116],\n", - " [0.06 , 0.079, 0.161, 0.164, 0.096, 0.068, 0.096, 0.072],\n", - " [0.058, 0.082, 0.161, 0.163, 0.103, 0.1 , 0.057, 0.045],\n", - " [0.069, 0.069, 0.163, 0.163, 0.086, 0.086, 0.083, 0.083],\n", - " [0.066, 0.066, 0.166, 0.166, 0.08 , 0.08 , 0.087, 0.087]]), array([[0. , 0.16 , 0.16 , 0.16 , 0.161, 0.161, 0.161, 0. ],\n", - " [0.016, 0.133, 0.162, 0.162, 0.107, 0.159, 0.159, 0.064],\n", - " [0.038, 0.117, 0.163, 0.163, 0.069, 0.148, 0.148, 0.088],\n", - " [0.045, 0.115, 0.164, 0.164, 0.048, 0.132, 0.132, 0.036],\n", - " [0.037, 0.125, 0.165, 0.165, 0.04 , 0.128, 0.128, 0.022],\n", - " [0.02 , 0.118, 0.163, 0.163, 0.141, 0.156, 0.156, 0.044],\n", - " [0.038, 0.114, 0.164, 0.148, 0.128, 0.11 , 0.148, 0.053],\n", - " [0.049, 0.11 , 0.144, 0.165, 0.097, 0.112, 0.131, 0.048],\n", - " [0.044, 0.118, 0.144, 0.165, 0.083, 0.104, 0.124, 0.048],\n", - " [0.047, 0.114, 0.145, 0.165, 0.08 , 0.107, 0.127, 0.056],\n", - " [0.047, 0.111, 0.148, 0.164, 0.09 , 0.147, 0.12 , 0.063],\n", - " [0.032, 0.118, 0.154, 0.163, 0.109, 0.159, 0.131, 0.074],\n", - " [0.048, 0.093, 0.165, 0.165, 0.113, 0.043, 0.144, 0.144],\n", - " [0.056, 0.089, 0.156, 0.165, 0.106, 0.055, 0.113, 0.126],\n", - " [0.057, 0.093, 0.151, 0.165, 0.096, 0.057, 0.095, 0.114],\n", - " [0.053, 0.098, 0.152, 0.165, 0.1 , 0.061, 0.123, 0.053],\n", - " [0.054, 0.095, 0.153, 0.165, 0.106, 0.151, 0.082, 0.067],\n", - " [0.063, 0.08 , 0.166, 0.166, 0.096, 0.062, 0.126, 0.126],\n", - " [0.066, 0.075, 0.163, 0.166, 0.089, 0.078, 0.108, 0.093],\n", - " [0.058, 0.08 , 0.166, 0.166, 0.094, 0.063, 0.137, 0.036],\n", - " [0.072, 0.072, 0.166, 0.166, 0.082, 0.082, 0.154, 0.154],\n", - " [0.05 , 0.099, 0.153, 0.161, 0.126, 0.072, 0.085, 0.134],\n", - " [0.055, 0.099, 0.147, 0.163, 0.102, 0.108, 0.062, 0.102],\n", - " [0.049, 0.107, 0.144, 0.164, 0.086, 0.114, 0.099, 0.024],\n", - " [0.062, 0.08 , 0.158, 0.165, 0.106, 0.062, 0.104, 0.116],\n", - " [0.06 , 0.079, 0.161, 0.164, 0.096, 0.068, 0.096, 0.072],\n", - " [0.058, 0.082, 0.161, 0.163, 0.103, 0.1 , 0.057, 0.045],\n", - " [0.069, 0.069, 0.163, 0.163, 0.086, 0.086, 0.083, 0.083],\n", - " [0.066, 0.066, 0.166, 0.166, 0.08 , 0.08 , 0.087, 0.087]]), array([[0. , 0.16 , 0.16 , 0.16 , 0.161, 0.161, 0.161, 0. ],\n", - " [0.016, 0.133, 0.162, 0.162, 0.107, 0.159, 0.159, 0.064],\n", - " [0.038, 0.117, 0.163, 0.163, 0.069, 0.148, 0.148, 0.088],\n", - " [0.045, 0.115, 0.164, 0.164, 0.048, 0.132, 0.132, 0.036],\n", - " [0.037, 0.125, 0.165, 0.165, 0.04 , 0.128, 0.128, 0.022],\n", - " [0.02 , 0.118, 0.163, 0.163, 0.141, 0.156, 0.156, 0.044],\n", - " [0.038, 0.114, 0.164, 0.148, 0.128, 0.11 , 0.148, 0.053],\n", - " [0.049, 0.11 , 0.144, 0.165, 0.097, 0.112, 0.131, 0.048],\n", - " [0.044, 0.118, 0.144, 0.165, 0.083, 0.104, 0.124, 0.048],\n", - " [0.047, 0.114, 0.145, 0.165, 0.08 , 0.107, 0.127, 0.056],\n", - " [0.047, 0.111, 0.148, 0.164, 0.09 , 0.147, 0.12 , 0.063],\n", - " [0.032, 0.118, 0.154, 0.163, 0.109, 0.159, 0.131, 0.074],\n", - " [0.048, 0.093, 0.165, 0.165, 0.113, 0.043, 0.144, 0.144],\n", - " [0.056, 0.089, 0.156, 0.165, 0.106, 0.055, 0.113, 0.126],\n", - " [0.057, 0.093, 0.151, 0.165, 0.096, 0.057, 0.095, 0.114],\n", - " [0.053, 0.098, 0.152, 0.165, 0.1 , 0.061, 0.123, 0.053],\n", - " [0.054, 0.095, 0.153, 0.165, 0.106, 0.151, 0.082, 0.067],\n", - " [0.063, 0.08 , 0.166, 0.166, 0.096, 0.062, 0.126, 0.126],\n", - " [0.066, 0.075, 0.163, 0.166, 0.089, 0.078, 0.108, 0.093],\n", - " [0.058, 0.08 , 0.166, 0.166, 0.094, 0.063, 0.137, 0.036],\n", - " [0.072, 0.072, 0.166, 0.166, 0.082, 0.082, 0.154, 0.154],\n", - " [0.05 , 0.099, 0.153, 0.161, 0.126, 0.072, 0.085, 0.134],\n", - " [0.055, 0.099, 0.147, 0.163, 0.102, 0.108, 0.062, 0.102],\n", - " [0.049, 0.107, 0.144, 0.164, 0.086, 0.114, 0.099, 0.024],\n", - " [0.062, 0.08 , 0.158, 0.165, 0.106, 0.062, 0.104, 0.116],\n", - " [0.06 , 0.079, 0.161, 0.164, 0.096, 0.068, 0.096, 0.072],\n", - " [0.058, 0.082, 0.161, 0.163, 0.103, 0.1 , 0.057, 0.045],\n", - " [0.069, 0.069, 0.163, 0.163, 0.086, 0.086, 0.083, 0.083],\n", - " [0.066, 0.066, 0.166, 0.166, 0.08 , 0.08 , 0.087, 0.087]]), array([[0.498, 0. , 0. , 0. , 0. , 0. , 0. , 0.494],\n", - " [0.45 , 0.088, 0. , 0. , 0.16 , 0. , 0. , 0.29 ],\n", - " [0.383, 0.142, 0. , 0. , 0.265, 0. , 0. , 0.179],\n", - " [0.362, 0.148, 0. , 0. , 0.321, 0. , 0. , 0.035],\n", - " [0.386, 0.119, 0. , 0. , 0.34 , 0. , 0. , 0.019],\n", - " [0.437, 0.133, 0. , 0. , 0.058, 0. , 0. , 0.325],\n", - " [0.382, 0.151, 0. , 0.048, 0.084, 0.141, 0. , 0.056],\n", - " [0.35 , 0.165, 0.063, 0. , 0.145, 0.09 , 0. , 0.067],\n", - " [0.366, 0.142, 0.064, 0. , 0.183, 0.077, 0. , 0.052],\n", - " [0.356, 0.153, 0.059, 0. , 0.2 , 0.057, 0. , 0.071],\n", - " [0.358, 0.163, 0.05 , 0. , 0.187, 0. , 0.04 , 0.119],\n", - " [0.402, 0.138, 0.028, 0. , 0.149, 0. , 0.06 , 0.17 ],\n", - " [0.354, 0.215, 0. , 0. , 0.135, 0.125, 0. , 0. ],\n", - " [0.328, 0.226, 0.029, 0. , 0.13 , 0.119, 0.053, 0. ],\n", - " [0.328, 0.215, 0.042, 0. , 0.126, 0.079, 0.109, 0. ],\n", - " [0.341, 0.201, 0.04 , 0. , 0.112, 0.086, 0. , 0.072],\n", - " [0.336, 0.21 , 0.037, 0. , 0.103, 0. , 0.077, 0.151],\n", - " [0.308, 0.256, 0. , 0. , 0.169, 0.146, 0. , 0. ],\n", - " [0.298, 0.272, 0.009, 0. , 0.156, 0.136, 0. , 0.038],\n", - " [0.324, 0.258, 0. , 0. , 0.135, 0.091, 0. , 0.057],\n", - " [0.282, 0.282, 0. , 0. , 0.17 , 0.17 , 0. , 0. ],\n", - " [0.348, 0.197, 0.035, 0.011, 0.081, 0.179, 0. , 0.016],\n", - " [0.334, 0.199, 0.054, 0.006, 0.1 , 0.063, 0.095, 0.029],\n", - " [0.351, 0.175, 0.063, 0.002, 0.163, 0.013, 0.042, 0.026],\n", - " [0.313, 0.257, 0.023, 0. , 0.118, 0.117, 0.052, 0.008],\n", - " [0.319, 0.26 , 0.013, 0.004, 0.101, 0.059, 0.095, 0.057],\n", - " [0.324, 0.25 , 0.014, 0.006, 0.075, 0.047, 0.103, 0.06 ],\n", - " [0.29 , 0.29 , 0.007, 0.007, 0.128, 0.129, 0.036, 0.036],\n", - " [0.3 , 0.3 , 0. , 0. , 0. , 0. , 0.158, 0.158]]), array([[0. , 0.16 , 0.16 , 0.16 , 0.161, 0.161, 0.161, 0. ],\n", - " [0.016, 0.133, 0.162, 0.162, 0.107, 0.159, 0.159, 0.064],\n", - " [0.038, 0.117, 0.163, 0.163, 0.069, 0.148, 0.148, 0.088],\n", - " [0.045, 0.115, 0.164, 0.164, 0.048, 0.132, 0.132, 0.036],\n", - " [0.037, 0.125, 0.165, 0.165, 0.04 , 0.128, 0.128, 0.022],\n", - " [0.02 , 0.118, 0.163, 0.163, 0.141, 0.156, 0.156, 0.044],\n", - " [0.038, 0.114, 0.164, 0.148, 0.128, 0.11 , 0.148, 0.053],\n", - " [0.049, 0.11 , 0.144, 0.165, 0.097, 0.112, 0.131, 0.048],\n", - " [0.044, 0.118, 0.144, 0.165, 0.083, 0.104, 0.124, 0.048],\n", - " [0.047, 0.114, 0.145, 0.165, 0.08 , 0.107, 0.127, 0.056],\n", - " [0.047, 0.111, 0.148, 0.164, 0.09 , 0.147, 0.12 , 0.063],\n", - " [0.032, 0.118, 0.154, 0.163, 0.109, 0.159, 0.131, 0.074],\n", - " [0.048, 0.093, 0.165, 0.165, 0.113, 0.043, 0.144, 0.144],\n", - " [0.056, 0.089, 0.156, 0.165, 0.106, 0.055, 0.113, 0.126],\n", - " [0.057, 0.093, 0.151, 0.165, 0.096, 0.057, 0.095, 0.114],\n", - " [0.053, 0.098, 0.152, 0.165, 0.1 , 0.061, 0.123, 0.053],\n", - " [0.054, 0.095, 0.153, 0.165, 0.106, 0.151, 0.082, 0.067],\n", - " [0.063, 0.08 , 0.166, 0.166, 0.096, 0.062, 0.126, 0.126],\n", - " [0.066, 0.075, 0.163, 0.166, 0.089, 0.078, 0.108, 0.093],\n", - " [0.058, 0.08 , 0.166, 0.166, 0.094, 0.063, 0.137, 0.036],\n", - " [0.072, 0.072, 0.166, 0.166, 0.082, 0.082, 0.154, 0.154],\n", - " [0.05 , 0.099, 0.153, 0.161, 0.126, 0.072, 0.085, 0.134],\n", - " [0.055, 0.099, 0.147, 0.163, 0.102, 0.108, 0.062, 0.102],\n", - " [0.049, 0.107, 0.144, 0.164, 0.086, 0.114, 0.099, 0.024],\n", - " [0.062, 0.08 , 0.158, 0.165, 0.106, 0.062, 0.104, 0.116],\n", - " [0.06 , 0.079, 0.161, 0.164, 0.096, 0.068, 0.096, 0.072],\n", - " [0.058, 0.082, 0.161, 0.163, 0.103, 0.1 , 0.057, 0.045],\n", - " [0.069, 0.069, 0.163, 0.163, 0.086, 0.086, 0.083, 0.083],\n", - " [0.066, 0.066, 0.166, 0.166, 0.08 , 0.08 , 0.087, 0.087]]), array([[0. , 0.16 , 0.16 , 0.16 , 0.161, 0.161, 0.161, 0. ],\n", - " [0.016, 0.133, 0.162, 0.162, 0.107, 0.159, 0.159, 0.064],\n", - " [0.038, 0.117, 0.163, 0.163, 0.069, 0.148, 0.148, 0.088],\n", - " [0.045, 0.115, 0.164, 0.164, 0.048, 0.132, 0.132, 0.036],\n", - " [0.037, 0.125, 0.165, 0.165, 0.04 , 0.128, 0.128, 0.022],\n", - " [0.02 , 0.118, 0.163, 0.163, 0.141, 0.156, 0.156, 0.044],\n", - " [0.038, 0.114, 0.164, 0.148, 0.128, 0.11 , 0.148, 0.053],\n", - " [0.049, 0.11 , 0.144, 0.165, 0.097, 0.112, 0.131, 0.048],\n", - " [0.044, 0.118, 0.144, 0.165, 0.083, 0.104, 0.124, 0.048],\n", - " [0.047, 0.114, 0.145, 0.165, 0.08 , 0.107, 0.127, 0.056],\n", - " [0.047, 0.111, 0.148, 0.164, 0.09 , 0.147, 0.12 , 0.063],\n", - " [0.032, 0.118, 0.154, 0.163, 0.109, 0.159, 0.131, 0.074],\n", - " [0.048, 0.093, 0.165, 0.165, 0.113, 0.043, 0.144, 0.144],\n", - " [0.056, 0.089, 0.156, 0.165, 0.106, 0.055, 0.113, 0.126],\n", - " [0.057, 0.093, 0.151, 0.165, 0.096, 0.057, 0.095, 0.114],\n", - " [0.053, 0.098, 0.152, 0.165, 0.1 , 0.061, 0.123, 0.053],\n", - " [0.054, 0.095, 0.153, 0.165, 0.106, 0.151, 0.082, 0.067],\n", - " [0.063, 0.08 , 0.166, 0.166, 0.096, 0.062, 0.126, 0.126],\n", - " [0.066, 0.075, 0.163, 0.166, 0.089, 0.078, 0.108, 0.093],\n", - " [0.058, 0.08 , 0.166, 0.166, 0.094, 0.063, 0.137, 0.036],\n", - " [0.072, 0.072, 0.166, 0.166, 0.082, 0.082, 0.154, 0.154],\n", - " [0.05 , 0.099, 0.153, 0.161, 0.126, 0.072, 0.085, 0.134],\n", - " [0.055, 0.099, 0.147, 0.163, 0.102, 0.108, 0.062, 0.102],\n", - " [0.049, 0.107, 0.144, 0.164, 0.086, 0.114, 0.099, 0.024],\n", - " [0.062, 0.08 , 0.158, 0.165, 0.106, 0.062, 0.104, 0.116],\n", - " [0.06 , 0.079, 0.161, 0.164, 0.096, 0.068, 0.096, 0.072],\n", - " [0.058, 0.082, 0.161, 0.163, 0.103, 0.1 , 0.057, 0.045],\n", - " [0.069, 0.069, 0.163, 0.163, 0.086, 0.086, 0.083, 0.083],\n", - " [0.066, 0.066, 0.166, 0.166, 0.08 , 0.08 , 0.087, 0.087]]), array([[0. , 0.16 , 0.16 , 0.16 , 0.161, 0.161, 0.161, 0. ],\n", - " [0.016, 0.133, 0.162, 0.162, 0.107, 0.159, 0.159, 0.064],\n", - " [0.038, 0.117, 0.163, 0.163, 0.069, 0.148, 0.148, 0.088],\n", - " [0.045, 0.115, 0.164, 0.164, 0.048, 0.132, 0.132, 0.036],\n", - " [0.037, 0.125, 0.165, 0.165, 0.04 , 0.128, 0.128, 0.022],\n", - " [0.02 , 0.118, 0.163, 0.163, 0.141, 0.156, 0.156, 0.044],\n", - " [0.038, 0.114, 0.164, 0.148, 0.128, 0.11 , 0.148, 0.053],\n", - " [0.049, 0.11 , 0.144, 0.165, 0.097, 0.112, 0.131, 0.048],\n", - " [0.044, 0.118, 0.144, 0.165, 0.083, 0.104, 0.124, 0.048],\n", - " [0.047, 0.114, 0.145, 0.165, 0.08 , 0.107, 0.127, 0.056],\n", - " [0.047, 0.111, 0.148, 0.164, 0.09 , 0.147, 0.12 , 0.063],\n", - " [0.032, 0.118, 0.154, 0.163, 0.109, 0.159, 0.131, 0.074],\n", - " [0.048, 0.093, 0.165, 0.165, 0.113, 0.043, 0.144, 0.144],\n", - " [0.056, 0.089, 0.156, 0.165, 0.106, 0.055, 0.113, 0.126],\n", - " [0.057, 0.093, 0.151, 0.165, 0.096, 0.057, 0.095, 0.114],\n", - " [0.053, 0.098, 0.152, 0.165, 0.1 , 0.061, 0.123, 0.053],\n", - " [0.054, 0.095, 0.153, 0.165, 0.106, 0.151, 0.082, 0.067],\n", - " [0.063, 0.08 , 0.166, 0.166, 0.096, 0.062, 0.126, 0.126],\n", - " [0.066, 0.075, 0.163, 0.166, 0.089, 0.078, 0.108, 0.093],\n", - " [0.058, 0.08 , 0.166, 0.166, 0.094, 0.063, 0.137, 0.036],\n", - " [0.072, 0.072, 0.166, 0.166, 0.082, 0.082, 0.154, 0.154],\n", - " [0.05 , 0.099, 0.153, 0.161, 0.126, 0.072, 0.085, 0.134],\n", - " [0.055, 0.099, 0.147, 0.163, 0.102, 0.108, 0.062, 0.102],\n", - " [0.049, 0.107, 0.144, 0.164, 0.086, 0.114, 0.099, 0.024],\n", - " [0.062, 0.08 , 0.158, 0.165, 0.106, 0.062, 0.104, 0.116],\n", - " [0.06 , 0.079, 0.161, 0.164, 0.096, 0.068, 0.096, 0.072],\n", - " [0.058, 0.082, 0.161, 0.163, 0.103, 0.1 , 0.057, 0.045],\n", - " [0.069, 0.069, 0.163, 0.163, 0.086, 0.086, 0.083, 0.083],\n", - " [0.066, 0.066, 0.166, 0.166, 0.08 , 0.08 , 0.087, 0.087]])], list_of_energy=[array([-6.166, -6.156, -6.146, ..., 16.714, 16.724, 16.734]), array([-6.166, -6.156, -6.146, ..., 16.714, 16.724, 16.734]), array([-6.166, -6.156, -6.146, ..., 16.714, 16.724, 16.734]), array([-6.166, -6.156, -6.146, ..., 16.714, 16.724, 16.734]), array([-6.166, -6.156, -6.146, ..., 16.714, 16.724, 16.734]), array([-6.166, -6.156, -6.146, ..., 16.714, 16.724, 16.734]), array([-6.166, -6.156, -6.146, ..., 16.714, 16.724, 16.734]), array([-6.166, -6.156, -6.146, ..., 16.714, 16.724, 16.734])], list_of_pdos=[array([9.96e-07, 1.54e-06, 2.35e-06, ..., 4.21e-12, 2.74e-12, 1.76e-12]), array([3.31e-12, 6.38e-12, 1.22e-11, ..., 3.34e-06, 2.17e-06, 1.40e-06]), array([3.31e-12, 6.38e-12, 1.22e-11, ..., 3.34e-06, 2.17e-06, 1.40e-06]), array([3.31e-12, 6.38e-12, 1.22e-11, ..., 3.34e-06, 2.17e-06, 1.40e-06]), array([9.96e-07, 1.54e-06, 2.35e-06, ..., 4.21e-12, 2.74e-12, 1.76e-12]), array([3.31e-12, 6.38e-12, 1.22e-11, ..., 3.34e-06, 2.17e-06, 1.40e-06]), array([3.31e-12, 6.38e-12, 1.22e-11, ..., 3.34e-06, 2.17e-06, 1.40e-06]), array([3.31e-12, 6.38e-12, 1.22e-11, ..., 3.34e-06, 2.17e-06, 1.40e-06])], bands_check=False, bands_data=BandStructure(path=BandPath(path='', cell=[3x3], special_points={}, kpts=[29x3]), energies=[1x29x8 values], reference=0.0))" - ] - }, - "execution_count": 14, - "metadata": {}, - "output_type": "execute_result" } ], "source": [ @@ -570,8 +191,8 @@ "input_data = {}\n", "calc = Espresso(profile=profile, template=ProjwfcTemplate(),\n", " input_data=input_data,\n", - " directory=\"test\",)\n", - "calc.get_property(\"projections\")" + " directory=\"calculation\",)\n", + "results = calc.get_property(\"projections\")" ] }, { @@ -583,16 +204,16 @@ }, { "cell_type": "code", - "execution_count": 15, + "execution_count": 2, "metadata": {}, "outputs": [ { "data": { "text/plain": [ - "" + "" ] }, - "execution_count": 15, + "execution_count": 2, "metadata": {}, "output_type": "execute_result" }, @@ -610,11 +231,9 @@ "source": [ "import matplotlib.pyplot as plt\n", "\n", - "#------------------------- Print the output -------------------------\n", "orbitals = calc.results[\"projections\"].orbitals\n", "pdos_data = calc.results[\"projections\"].list_of_pdos\n", "energy_data = calc.results[\"projections\"].list_of_energy\n", - "# make plots\n", "plt.figure(figsize = (8, 4))\n", "for i in range(len(pdos_data)):\n", " orbital_data = orbitals[i].get_orbital_dict()\n", @@ -622,7 +241,6 @@ " orbital = orbitals[i].get_name_from_quantum_numbers(orbital_data[\"angular_momentum\"], orbital_data[\"magnetic_number\"]\n", " ).lower()\n", " plt.plot(energy_data[i], pdos_data[i], label=f\"{kind_name}-{orbital}\")\n", - "# plt.plot(pdos_data['totol']['energy'], pdos_data['totol']['dos'], label='total')\n", "plt.yticks([])\n", "plt.xlabel('Energy (eV)')\n", "plt.ylabel('DOS')\n", diff --git a/src/ase_quantumespresso/__init__.py b/src/ase_quantumespresso/__init__.py index baef9a8..09a74c9 100644 --- a/src/ase_quantumespresso/__init__.py +++ b/src/ase_quantumespresso/__init__.py @@ -5,4 +5,11 @@ from .ld1 import Ld1Template -__all__ = ["Espresso", "PwTemplate", "DosTemplate", "ProjwfcTemplate", "PpTemplate", "Ld1Template"] +__all__ = [ + "Espresso", + "PwTemplate", + "DosTemplate", + "ProjwfcTemplate", + "PpTemplate", + "Ld1Template", +] diff --git a/src/ase_quantumespresso/ld1.py b/src/ase_quantumespresso/ld1.py index 37614e7..210045c 100644 --- a/src/ase_quantumespresso/ld1.py +++ b/src/ase_quantumespresso/ld1.py @@ -1,8 +1,9 @@ from .namelist import NamelistTemplate -import re + class Ld1Template(NamelistTemplate): _label = "ld1" + outputname = "ld1.ld1o" def __init__(self): super().__init__( @@ -13,6 +14,7 @@ def __init__(self): def write_input(self, profile, directory, atoms, parameters, properties): from ase.io.espresso_namelist.keys import ld1_keys + # I removed the "test" key from ld1_keys, because it was causing the following error: # Error: reading number of pseudo wavefunctions (nwfs) ld1_keys.pop("test") @@ -22,38 +24,11 @@ def write_input(self, profile, directory, atoms, parameters, properties): super().write_input(profile, directory, atoms, parameters, properties) def read_results(self, directory): - path = directory / "ld1.ld1o" - with open(path, "r") as f: - energy_data = parse_energy_totals(f.read()) - - return {"ld1": energy_data} - - + from .parsers.ld1 import Ld1Parser -def parse_energy_totals(text): - # Pattern to find Etot and Etotps lines and capture relevant parts - etot_pattern = r"Etot\s+=\s+([-\d\.]+)\s+Ry,\s+([-\d\.]+)\s+Ha,\s+([-\d\.]+)\s+eV" - etotps_pattern = r"Etotps\s+=\s+([-\d\.]+)\s+Ry,\s+([-\d\.]+)\s+Ha,\s+([-\d\.]+)\s+eV" - - # Search for patterns and extract values - etot_match = re.search(etot_pattern, text) - etotps_match = re.search(etotps_pattern, text) - - # Structured data - energy_data = {} - - if etot_match: - energy_data['Etot'] = { - 'Ry': float(etot_match.group(1)), - 'Ha': float(etot_match.group(2)), - 'eV': float(etot_match.group(3)) - } - - if etotps_match: - energy_data['Etotps'] = { - 'Ry': float(etotps_match.group(1)), - 'Ha': float(etotps_match.group(2)), - 'eV': float(etotps_match.group(3)) - } - - return energy_data \ No newline at end of file + parser = Ld1Parser(directory, self.outputname) + exit_code = parser.parse() + results = parser.results + results["exit_code"] = exit_code + print("results", results) + return results diff --git a/src/ase_quantumespresso/parsers/__init__.py b/src/ase_quantumespresso/parsers/__init__.py index 46a0fd4..c2ba194 100644 --- a/src/ase_quantumespresso/parsers/__init__.py +++ b/src/ase_quantumespresso/parsers/__init__.py @@ -1,5 +1,6 @@ from .pw import PwParser from .dos import DosParser from .projwfc import ProjwfcParser +from .ld1 import Ld1Parser -__all__ = [PwParser, DosParser, ProjwfcParser] +__all__ = [PwParser, DosParser, ProjwfcParser, Ld1Parser] diff --git a/src/ase_quantumespresso/parsers/dos.py b/src/ase_quantumespresso/parsers/dos.py index a2c1f23..e14117e 100644 --- a/src/ase_quantumespresso/parsers/dos.py +++ b/src/ase_quantumespresso/parsers/dos.py @@ -4,7 +4,6 @@ Modified from aiida-quantumespresso.parsers.dos.DosParser. """ -# from aiida_quantumespresso.calculations.pw import PwCalculation from aiida_quantumespresso.utils.mapping import get_logging_container from .exit_code import DosExitCodes from .base import BaseParser diff --git a/src/ase_quantumespresso/parsers/exit_code.py b/src/ase_quantumespresso/parsers/exit_code.py index 82f7e95..46fe290 100644 --- a/src/ase_quantumespresso/parsers/exit_code.py +++ b/src/ase_quantumespresso/parsers/exit_code.py @@ -120,7 +120,7 @@ class PwExitCodes: @dataclass(frozen=True) -class NamelistsCalculation: +class NamelistsExitCodes: ERROR_OUTPUT_STDOUT_MISSING: ExitCode = ExitCode( 302, "The folder did not contain the required stdout output file." ) @@ -139,14 +139,14 @@ class NamelistsCalculation: @dataclass(frozen=True) -class DosExitCodes(NamelistsCalculation): +class DosExitCodes(NamelistsExitCodes): ERROR_OUTPUT_STDOUT_MISSING: ExitCode = ExitCode( 302, "The folder did not contain the required stdout output file." ) @dataclass(frozen=True) -class ProjwfcExitCodes(NamelistsCalculation): +class ProjwfcExitCodes(NamelistsExitCodes): ERROR_NO_RETRIEVED_TEMPORARY_FOLDER: ExitCode = ExitCode( 301, "The retrieved temporary folder could not be accessed." ) diff --git a/src/ase_quantumespresso/parsers/ld1.py b/src/ase_quantumespresso/parsers/ld1.py new file mode 100644 index 0000000..2b69832 --- /dev/null +++ b/src/ase_quantumespresso/parsers/ld1.py @@ -0,0 +1,80 @@ +# -*- coding: utf-8 -*- +"""`Parser` implementation for the `ld1.x` code of Quantum ESPRESSO. + +""" + +from aiida_quantumespresso.utils.mapping import get_logging_container +from .exit_code import NamelistsExitCodes +from .base import BaseParser +import re + + +class Ld1Parser(BaseParser): + """`Parser` implementation for the `dos.x` calculation, modified from aiida-quantumespresso.""" + + success_string = "End of pseudopotential test" + + def __init__(self, directory, outputname): + """Initialize the instance of `PwParser`.""" + super().__init__(directory, output_filename=outputname) + self.outputname = outputname + self.exit_codes = NamelistsExitCodes() + + def parse(self, **kwargs): + """Parse the retrieved files of a ``DosCalculation`` into output nodes.""" + + logs = get_logging_container() + + _, parsed_stdout, logs = self.parse_stdout_from_retrieved(logs) + + base_exit_code = self.check_base_errors(logs) + if base_exit_code: + return self.exit(base_exit_code, logs) + + self.out("output_parameters", parsed_stdout) + + if "ERROR_OUTPUT_STDOUT_INCOMPLETE" in logs.error: + return self.exit(self.exit_codes.ERROR_OUTPUT_STDOUT_INCOMPLETE, logs) + + # Parse the Energy + filepath_dos = self.directory / self.outputname + try: + with open(filepath_dos, "r") as handle: + text = handle.read() + energy_data = parse_energy_totals(text) + self.out("ld1", energy_data) + except OSError: + return self.exit(self.exit_codes.ERROR_READING_DOS_FILE, logs) + + return self.exit(logs=logs) + + +def parse_energy_totals(text): + # Pattern to find Etot and Etotps lines and capture relevant parts + etot_pattern = r"Etot\s+=\s+([-\d\.]+)\s+Ry,\s+([-\d\.]+)\s+Ha,\s+([-\d\.]+)\s+eV" + etotps_pattern = ( + r"Etotps\s+=\s+([-\d\.]+)\s+Ry,\s+([-\d\.]+)\s+Ha,\s+([-\d\.]+)\s+eV" + ) + + # Search for patterns and extract values + etot_match = re.search(etot_pattern, text) + etotps_match = re.search(etotps_pattern, text) + + # Structured data + energy_data = {} + + if etot_match: + energy_data["Etot"] = { + "Ry": float(etot_match.group(1)), + "Ha": float(etot_match.group(2)), + "eV": float(etot_match.group(3)), + } + + if etotps_match: + energy_data["Etotps"] = { + "Ry": float(etotps_match.group(1)), + "Ha": float(etotps_match.group(2)), + "eV": float(etotps_match.group(3)), + } + + return energy_data diff --git a/src/ase_quantumespresso/parsers/projwfc.py b/src/ase_quantumespresso/parsers/projwfc.py index f0222de..215175c 100644 --- a/src/ase_quantumespresso/parsers/projwfc.py +++ b/src/ase_quantumespresso/parsers/projwfc.py @@ -122,7 +122,6 @@ def parse(self, **kwargs): Dos_out["y"] = {"arrays": dos, "labels": "Dos", "units": "states/eV"} self.out("dos", Dos_out) - print("results: ", self.results.keys()) return self.exit(logs=logs) def _parse_xml(self, retrieved_temporary_folder): diff --git a/src/ase_quantumespresso/projwfc.py b/src/ase_quantumespresso/projwfc.py index 325c3ef..836b190 100644 --- a/src/ase_quantumespresso/projwfc.py +++ b/src/ase_quantumespresso/projwfc.py @@ -20,5 +20,4 @@ def read_results(self, directory): exit_code = parser.parse() results = parser.results results["exit_code"] = exit_code - print("results: ", results.keys()) return results diff --git a/tests/test_ld1.py b/tests/test_ld1.py new file mode 100644 index 0000000..6c7610a --- /dev/null +++ b/tests/test_ld1.py @@ -0,0 +1,50 @@ +from ase_quantumespresso.espresso import Espresso, EspressoProfile +from ase_quantumespresso.ld1 import Ld1Template + +input_data = { + "input": { + "title": "Pt", + "zed": 78.0, + "rel": 1, + "config": "[Xe] 4f13 6s1 6p0 5d9", + "iswitch": 3, + "dft": "PBE", + }, + "inputp": { + "lpaw": True, + "use_xsd": False, + "pseudotype": 3, + "file_pseudopw": "Pt.star4f.pbe-n-kjpaw_psl.1.0.0.UPF", + "author": "Test", + "lloc": -1, + "rcloc": 2.4, + "which_augfun": "PSQ", + "rmatch_augfun_nc": True, + "nlcc": True, + "new_core_ps": True, + "rcore": 1.8, + "tm": True, + }, +} +pseudo_potential_test_cards = """ +6 +6S 1 0 1.00 0.00 2.00 2.20 0.0 +6S 1 0 0.00 4.40 2.00 2.20 0.0 +6P 2 1 0.00 0.00 2.30 2.50 0.0 +6P 2 1 0.00 6.40 2.30 2.50 0.0 +5D 3 2 9.00 0.00 1.00 2.20 0.0 +5D 3 2 0.00 0.80 1.00 2.20 0.0 +""" + + +def test_base_ld1(): + profile = EspressoProfile(command="ld1.x", pseudo_dir=".") + calc = Espresso( + directory="calculatioin", + profile=profile, + template=Ld1Template(), + input_data=input_data, + pseudo_potential_test_cards=pseudo_potential_test_cards, + ) + calc.get_property("ld1") + assert calc.results["exit_code"].status == 0 diff --git a/tests/test_pw.py b/tests/test_pw.py index edda039..a17f2a9 100644 --- a/tests/test_pw.py +++ b/tests/test_pw.py @@ -4,7 +4,7 @@ def test_pw(bulk_si, pseudopotentials, pseudo_dir, pw_input_data): profile = EspressoProfile(command="pw.x", pseudo_dir=pseudo_dir) calc = Espresso( - directory="test", + directory="calculatioin", profile=profile, pseudopotentials=pseudopotentials, input_data=pw_input_data,