From c29661899edc34bbf1298679dbdf447258042e61 Mon Sep 17 00:00:00 2001
From: M <35793078+PhysXu@users.noreply.github.com>
Date: Sun, 25 Aug 2024 14:34:52 +0800
Subject: [PATCH] Add files via upload
---
writeXYZ for Prismatic.ipynb | 769 +++++++++++++++++++++++++++++++++++
1 file changed, 769 insertions(+)
create mode 100644 writeXYZ for Prismatic.ipynb
diff --git a/writeXYZ for Prismatic.ipynb b/writeXYZ for Prismatic.ipynb
new file mode 100644
index 0000000..5c12bc6
--- /dev/null
+++ b/writeXYZ for Prismatic.ipynb
@@ -0,0 +1,769 @@
+{
+ "cells": [
+ {
+ "cell_type": "code",
+ "execution_count": 1,
+ "id": "1000b5d1-3e37-4712-95a4-4ede6d3a7b93",
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "import pandas as pd"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 2,
+ "id": "b3e5f906-5e09-4529-be1c-5107b3bf358c",
+ "metadata": {},
+ "outputs": [
+ {
+ "data": {
+ "text/html": [
+ "
\n",
+ "\n",
+ "
\n",
+ " \n",
+ " \n",
+ " | \n",
+ " Element | \n",
+ " X | \n",
+ " Y | \n",
+ " Z | \n",
+ "
\n",
+ " \n",
+ " \n",
+ " \n",
+ " 0 | \n",
+ " Li | \n",
+ " 0.000000 | \n",
+ " 0.000000 | \n",
+ " 0.000000 | \n",
+ "
\n",
+ " \n",
+ " 1 | \n",
+ " Li | \n",
+ " 0.000000 | \n",
+ " 0.000000 | \n",
+ " 14.145616 | \n",
+ "
\n",
+ " \n",
+ " 2 | \n",
+ " Li | \n",
+ " 0.000000 | \n",
+ " 24.620222 | \n",
+ " 0.000000 | \n",
+ "
\n",
+ " \n",
+ " 3 | \n",
+ " Li | \n",
+ " 0.000000 | \n",
+ " 24.620222 | \n",
+ " 14.145616 | \n",
+ "
\n",
+ " \n",
+ " 4 | \n",
+ " Li | \n",
+ " 14.214491 | \n",
+ " 0.000000 | \n",
+ " 0.000000 | \n",
+ "
\n",
+ " \n",
+ " ... | \n",
+ " ... | \n",
+ " ... | \n",
+ " ... | \n",
+ " ... | \n",
+ "
\n",
+ " \n",
+ " 1008 | \n",
+ " O | \n",
+ " 5.685796 | \n",
+ " 26.261570 | \n",
+ " 8.104311 | \n",
+ "
\n",
+ " \n",
+ " 1009 | \n",
+ " O | \n",
+ " 8.528695 | \n",
+ " -1.641348 | \n",
+ " 6.041305 | \n",
+ "
\n",
+ " \n",
+ " 1010 | \n",
+ " O | \n",
+ " 8.528695 | \n",
+ " 26.261570 | \n",
+ " 8.104311 | \n",
+ "
\n",
+ " \n",
+ " 1011 | \n",
+ " O | \n",
+ " 11.371593 | \n",
+ " -1.641348 | \n",
+ " 6.041305 | \n",
+ "
\n",
+ " \n",
+ " 1012 | \n",
+ " O | \n",
+ " 11.371593 | \n",
+ " 26.261570 | \n",
+ " 8.104311 | \n",
+ "
\n",
+ " \n",
+ "
\n",
+ "
1013 rows × 4 columns
\n",
+ "
"
+ ],
+ "text/plain": [
+ " Element X Y Z\n",
+ "0 Li 0.000000 0.000000 0.000000\n",
+ "1 Li 0.000000 0.000000 14.145616\n",
+ "2 Li 0.000000 24.620222 0.000000\n",
+ "3 Li 0.000000 24.620222 14.145616\n",
+ "4 Li 14.214491 0.000000 0.000000\n",
+ "... ... ... ... ...\n",
+ "1008 O 5.685796 26.261570 8.104311\n",
+ "1009 O 8.528695 -1.641348 6.041305\n",
+ "1010 O 8.528695 26.261570 8.104311\n",
+ "1011 O 11.371593 -1.641348 6.041305\n",
+ "1012 O 11.371593 26.261570 8.104311\n",
+ "\n",
+ "[1013 rows x 4 columns]"
+ ]
+ },
+ "execution_count": 2,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
+ "source": [
+ "column_names = ['Element', 'X', 'Y', 'Z']\n",
+ "coords = pd.read_excel(r'C:\\Users\\STEM\\Desktop\\LiCoO2 initial.xlsx', header=None, names=column_names)\n",
+ "coords"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 3,
+ "id": "110f4169-b74c-49eb-bd41-664b0358225b",
+ "metadata": {},
+ "outputs": [
+ {
+ "data": {
+ "text/html": [
+ "\n",
+ "\n",
+ "
\n",
+ " \n",
+ " \n",
+ " | \n",
+ " Element | \n",
+ " X | \n",
+ " Y | \n",
+ " Z | \n",
+ " occupancy | \n",
+ " isotropic thermal parameters | \n",
+ "
\n",
+ " \n",
+ " \n",
+ " \n",
+ " 0 | \n",
+ " Li | \n",
+ " 0.000000 | \n",
+ " 0.000000 | \n",
+ " 0.000000 | \n",
+ " 1 | \n",
+ " 0.08 | \n",
+ "
\n",
+ " \n",
+ " 1 | \n",
+ " Li | \n",
+ " 0.000000 | \n",
+ " 0.000000 | \n",
+ " 14.145616 | \n",
+ " 1 | \n",
+ " 0.08 | \n",
+ "
\n",
+ " \n",
+ " 2 | \n",
+ " Li | \n",
+ " 0.000000 | \n",
+ " 24.620222 | \n",
+ " 0.000000 | \n",
+ " 1 | \n",
+ " 0.08 | \n",
+ "
\n",
+ " \n",
+ " 3 | \n",
+ " Li | \n",
+ " 0.000000 | \n",
+ " 24.620222 | \n",
+ " 14.145616 | \n",
+ " 1 | \n",
+ " 0.08 | \n",
+ "
\n",
+ " \n",
+ " 4 | \n",
+ " Li | \n",
+ " 14.214491 | \n",
+ " 0.000000 | \n",
+ " 0.000000 | \n",
+ " 1 | \n",
+ " 0.08 | \n",
+ "
\n",
+ " \n",
+ " ... | \n",
+ " ... | \n",
+ " ... | \n",
+ " ... | \n",
+ " ... | \n",
+ " ... | \n",
+ " ... | \n",
+ "
\n",
+ " \n",
+ " 1008 | \n",
+ " O | \n",
+ " 5.685796 | \n",
+ " 26.261570 | \n",
+ " 8.104311 | \n",
+ " 1 | \n",
+ " 0.08 | \n",
+ "
\n",
+ " \n",
+ " 1009 | \n",
+ " O | \n",
+ " 8.528695 | \n",
+ " -1.641348 | \n",
+ " 6.041305 | \n",
+ " 1 | \n",
+ " 0.08 | \n",
+ "
\n",
+ " \n",
+ " 1010 | \n",
+ " O | \n",
+ " 8.528695 | \n",
+ " 26.261570 | \n",
+ " 8.104311 | \n",
+ " 1 | \n",
+ " 0.08 | \n",
+ "
\n",
+ " \n",
+ " 1011 | \n",
+ " O | \n",
+ " 11.371593 | \n",
+ " -1.641348 | \n",
+ " 6.041305 | \n",
+ " 1 | \n",
+ " 0.08 | \n",
+ "
\n",
+ " \n",
+ " 1012 | \n",
+ " O | \n",
+ " 11.371593 | \n",
+ " 26.261570 | \n",
+ " 8.104311 | \n",
+ " 1 | \n",
+ " 0.08 | \n",
+ "
\n",
+ " \n",
+ "
\n",
+ "
1013 rows × 6 columns
\n",
+ "
"
+ ],
+ "text/plain": [
+ " Element X Y Z occupancy \\\n",
+ "0 Li 0.000000 0.000000 0.000000 1 \n",
+ "1 Li 0.000000 0.000000 14.145616 1 \n",
+ "2 Li 0.000000 24.620222 0.000000 1 \n",
+ "3 Li 0.000000 24.620222 14.145616 1 \n",
+ "4 Li 14.214491 0.000000 0.000000 1 \n",
+ "... ... ... ... ... ... \n",
+ "1008 O 5.685796 26.261570 8.104311 1 \n",
+ "1009 O 8.528695 -1.641348 6.041305 1 \n",
+ "1010 O 8.528695 26.261570 8.104311 1 \n",
+ "1011 O 11.371593 -1.641348 6.041305 1 \n",
+ "1012 O 11.371593 26.261570 8.104311 1 \n",
+ "\n",
+ " isotropic thermal parameters \n",
+ "0 0.08 \n",
+ "1 0.08 \n",
+ "2 0.08 \n",
+ "3 0.08 \n",
+ "4 0.08 \n",
+ "... ... \n",
+ "1008 0.08 \n",
+ "1009 0.08 \n",
+ "1010 0.08 \n",
+ "1011 0.08 \n",
+ "1012 0.08 \n",
+ "\n",
+ "[1013 rows x 6 columns]"
+ ]
+ },
+ "execution_count": 3,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
+ "source": [
+ "# Add the occupancy and isotropic thermal parameters\n",
+ "\n",
+ "coords['occupancy']=1\n",
+ "coords['isotropic thermal parameters']=0.08\n",
+ "coords"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 4,
+ "id": "3ca4b865-37e7-4123-809d-e2b10dfecf19",
+ "metadata": {},
+ "outputs": [
+ {
+ "data": {
+ "text/html": [
+ "\n",
+ "\n",
+ "
\n",
+ " \n",
+ " \n",
+ " | \n",
+ " Element | \n",
+ " X | \n",
+ " Y | \n",
+ " Z | \n",
+ " occupancy | \n",
+ " isotropic thermal parameters | \n",
+ "
\n",
+ " \n",
+ " \n",
+ " \n",
+ " 0 | \n",
+ " Li | \n",
+ " 0.000000 | \n",
+ " 0.000000 | \n",
+ " 0.000000 | \n",
+ " 1 | \n",
+ " 0.06 | \n",
+ "
\n",
+ " \n",
+ " 1 | \n",
+ " Li | \n",
+ " 0.000000 | \n",
+ " 0.000000 | \n",
+ " 14.145616 | \n",
+ " 1 | \n",
+ " 0.06 | \n",
+ "
\n",
+ " \n",
+ " 2 | \n",
+ " Li | \n",
+ " 0.000000 | \n",
+ " 24.620222 | \n",
+ " 0.000000 | \n",
+ " 1 | \n",
+ " 0.06 | \n",
+ "
\n",
+ " \n",
+ " 3 | \n",
+ " Li | \n",
+ " 0.000000 | \n",
+ " 24.620222 | \n",
+ " 14.145616 | \n",
+ " 1 | \n",
+ " 0.06 | \n",
+ "
\n",
+ " \n",
+ " 4 | \n",
+ " Li | \n",
+ " 14.214491 | \n",
+ " 0.000000 | \n",
+ " 0.000000 | \n",
+ " 1 | \n",
+ " 0.06 | \n",
+ "
\n",
+ " \n",
+ " ... | \n",
+ " ... | \n",
+ " ... | \n",
+ " ... | \n",
+ " ... | \n",
+ " ... | \n",
+ " ... | \n",
+ "
\n",
+ " \n",
+ " 1008 | \n",
+ " O | \n",
+ " 5.685796 | \n",
+ " 26.261570 | \n",
+ " 8.104311 | \n",
+ " 1 | \n",
+ " 0.08 | \n",
+ "
\n",
+ " \n",
+ " 1009 | \n",
+ " O | \n",
+ " 8.528695 | \n",
+ " -1.641348 | \n",
+ " 6.041305 | \n",
+ " 1 | \n",
+ " 0.08 | \n",
+ "
\n",
+ " \n",
+ " 1010 | \n",
+ " O | \n",
+ " 8.528695 | \n",
+ " 26.261570 | \n",
+ " 8.104311 | \n",
+ " 1 | \n",
+ " 0.08 | \n",
+ "
\n",
+ " \n",
+ " 1011 | \n",
+ " O | \n",
+ " 11.371593 | \n",
+ " -1.641348 | \n",
+ " 6.041305 | \n",
+ " 1 | \n",
+ " 0.08 | \n",
+ "
\n",
+ " \n",
+ " 1012 | \n",
+ " O | \n",
+ " 11.371593 | \n",
+ " 26.261570 | \n",
+ " 8.104311 | \n",
+ " 1 | \n",
+ " 0.08 | \n",
+ "
\n",
+ " \n",
+ "
\n",
+ "
1013 rows × 6 columns
\n",
+ "
"
+ ],
+ "text/plain": [
+ " Element X Y Z occupancy \\\n",
+ "0 Li 0.000000 0.000000 0.000000 1 \n",
+ "1 Li 0.000000 0.000000 14.145616 1 \n",
+ "2 Li 0.000000 24.620222 0.000000 1 \n",
+ "3 Li 0.000000 24.620222 14.145616 1 \n",
+ "4 Li 14.214491 0.000000 0.000000 1 \n",
+ "... ... ... ... ... ... \n",
+ "1008 O 5.685796 26.261570 8.104311 1 \n",
+ "1009 O 8.528695 -1.641348 6.041305 1 \n",
+ "1010 O 8.528695 26.261570 8.104311 1 \n",
+ "1011 O 11.371593 -1.641348 6.041305 1 \n",
+ "1012 O 11.371593 26.261570 8.104311 1 \n",
+ "\n",
+ " isotropic thermal parameters \n",
+ "0 0.06 \n",
+ "1 0.06 \n",
+ "2 0.06 \n",
+ "3 0.06 \n",
+ "4 0.06 \n",
+ "... ... \n",
+ "1008 0.08 \n",
+ "1009 0.08 \n",
+ "1010 0.08 \n",
+ "1011 0.08 \n",
+ "1012 0.08 \n",
+ "\n",
+ "[1013 rows x 6 columns]"
+ ]
+ },
+ "execution_count": 4,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
+ "source": [
+ "# If you want use different Uiso for different elements, run the Cell\n",
+ "\n",
+ "coords.loc[coords['Element'] == 'Li', 'isotropic thermal parameters'] = 0.06\n",
+ "coords"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 5,
+ "id": "8df9ecc5-851d-47c5-8f42-3c57e0e8a78c",
+ "metadata": {},
+ "outputs": [
+ {
+ "name": "stderr",
+ "output_type": "stream",
+ "text": [
+ "C:\\Users\\STEM\\AppData\\Local\\Temp\\ipykernel_1928\\469350156.py:1: FutureWarning: Downcasting behavior in `replace` is deprecated and will be removed in a future version. To retain the old behavior, explicitly call `result.infer_objects(copy=False)`. To opt-in to the future behavior, set `pd.set_option('future.no_silent_downcasting', True)`\n",
+ " coords['Element'] = coords['Element'].replace({'Li': 3, 'Co': 27, 'O': 8})\n"
+ ]
+ },
+ {
+ "data": {
+ "text/html": [
+ "\n",
+ "\n",
+ "
\n",
+ " \n",
+ " \n",
+ " | \n",
+ " Element | \n",
+ " X | \n",
+ " Y | \n",
+ " Z | \n",
+ " occupancy | \n",
+ " isotropic thermal parameters | \n",
+ "
\n",
+ " \n",
+ " \n",
+ " \n",
+ " 0 | \n",
+ " 3 | \n",
+ " 0.000000 | \n",
+ " 0.000000 | \n",
+ " 0.000000 | \n",
+ " 1 | \n",
+ " 0.06 | \n",
+ "
\n",
+ " \n",
+ " 1 | \n",
+ " 3 | \n",
+ " 0.000000 | \n",
+ " 0.000000 | \n",
+ " 14.145616 | \n",
+ " 1 | \n",
+ " 0.06 | \n",
+ "
\n",
+ " \n",
+ " 2 | \n",
+ " 3 | \n",
+ " 0.000000 | \n",
+ " 24.620222 | \n",
+ " 0.000000 | \n",
+ " 1 | \n",
+ " 0.06 | \n",
+ "
\n",
+ " \n",
+ " 3 | \n",
+ " 3 | \n",
+ " 0.000000 | \n",
+ " 24.620222 | \n",
+ " 14.145616 | \n",
+ " 1 | \n",
+ " 0.06 | \n",
+ "
\n",
+ " \n",
+ " 4 | \n",
+ " 3 | \n",
+ " 14.214491 | \n",
+ " 0.000000 | \n",
+ " 0.000000 | \n",
+ " 1 | \n",
+ " 0.06 | \n",
+ "
\n",
+ " \n",
+ " ... | \n",
+ " ... | \n",
+ " ... | \n",
+ " ... | \n",
+ " ... | \n",
+ " ... | \n",
+ " ... | \n",
+ "
\n",
+ " \n",
+ " 1008 | \n",
+ " 8 | \n",
+ " 5.685796 | \n",
+ " 26.261570 | \n",
+ " 8.104311 | \n",
+ " 1 | \n",
+ " 0.08 | \n",
+ "
\n",
+ " \n",
+ " 1009 | \n",
+ " 8 | \n",
+ " 8.528695 | \n",
+ " -1.641348 | \n",
+ " 6.041305 | \n",
+ " 1 | \n",
+ " 0.08 | \n",
+ "
\n",
+ " \n",
+ " 1010 | \n",
+ " 8 | \n",
+ " 8.528695 | \n",
+ " 26.261570 | \n",
+ " 8.104311 | \n",
+ " 1 | \n",
+ " 0.08 | \n",
+ "
\n",
+ " \n",
+ " 1011 | \n",
+ " 8 | \n",
+ " 11.371593 | \n",
+ " -1.641348 | \n",
+ " 6.041305 | \n",
+ " 1 | \n",
+ " 0.08 | \n",
+ "
\n",
+ " \n",
+ " 1012 | \n",
+ " 8 | \n",
+ " 11.371593 | \n",
+ " 26.261570 | \n",
+ " 8.104311 | \n",
+ " 1 | \n",
+ " 0.08 | \n",
+ "
\n",
+ " \n",
+ "
\n",
+ "
1013 rows × 6 columns
\n",
+ "
"
+ ],
+ "text/plain": [
+ " Element X Y Z occupancy \\\n",
+ "0 3 0.000000 0.000000 0.000000 1 \n",
+ "1 3 0.000000 0.000000 14.145616 1 \n",
+ "2 3 0.000000 24.620222 0.000000 1 \n",
+ "3 3 0.000000 24.620222 14.145616 1 \n",
+ "4 3 14.214491 0.000000 0.000000 1 \n",
+ "... ... ... ... ... ... \n",
+ "1008 8 5.685796 26.261570 8.104311 1 \n",
+ "1009 8 8.528695 -1.641348 6.041305 1 \n",
+ "1010 8 8.528695 26.261570 8.104311 1 \n",
+ "1011 8 11.371593 -1.641348 6.041305 1 \n",
+ "1012 8 11.371593 26.261570 8.104311 1 \n",
+ "\n",
+ " isotropic thermal parameters \n",
+ "0 0.06 \n",
+ "1 0.06 \n",
+ "2 0.06 \n",
+ "3 0.06 \n",
+ "4 0.06 \n",
+ "... ... \n",
+ "1008 0.08 \n",
+ "1009 0.08 \n",
+ "1010 0.08 \n",
+ "1011 0.08 \n",
+ "1012 0.08 \n",
+ "\n",
+ "[1013 rows x 6 columns]"
+ ]
+ },
+ "execution_count": 5,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
+ "source": [
+ "# Chnage the Element to the element_No.\n",
+ "\n",
+ "coords['Element'] = coords['Element'].replace({'Li': 3, 'Co': 27, 'O': 8})\n",
+ "coords"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 6,
+ "id": "3bee4319-3b82-4701-b9f3-4cc9e4f7e796",
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "fileName = r'C:\\Users\\STEM\\Desktop\\LiCoO2 final.xyz'\n",
+ "comment = 'LiCoO2'\n",
+ "cellDim = [14.214, 24.620, 14.146] # the size of cell\n",
+ "\n",
+ "with open(fileName, 'w') as fid:\n",
+ " # Write comment line (1st)\n",
+ " fid.write(f\"{comment}\\n\")\n",
+ "\n",
+ " # Write cell dimensions\n",
+ " fid.write(f\" {cellDim[0]} {cellDim[1]} {cellDim[2]}\\n\")\n",
+ "\n",
+ " # Write atomic data\n",
+ " dataAll = coords.values\n",
+ " for row in dataAll:\n",
+ " fid.write(f\"{int(row[0])} {row[1]:.6f} {row[2]:.6f} {row[3]:.6f} {int(row[4])} {row[5]:.6f}\\n\")\n",
+ "\n",
+ " # Write end of file, for compatibility\n",
+ " fid.write(\"-1\\n\")"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "id": "45732bd6-135b-4e1a-a7dc-7b4fe5b6af95",
+ "metadata": {},
+ "outputs": [],
+ "source": []
+ }
+ ],
+ "metadata": {
+ "kernelspec": {
+ "display_name": "Python 3 (ipykernel)",
+ "language": "python",
+ "name": "python3"
+ },
+ "language_info": {
+ "codemirror_mode": {
+ "name": "ipython",
+ "version": 3
+ },
+ "file_extension": ".py",
+ "mimetype": "text/x-python",
+ "name": "python",
+ "nbconvert_exporter": "python",
+ "pygments_lexer": "ipython3",
+ "version": "3.10.14"
+ }
+ },
+ "nbformat": 4,
+ "nbformat_minor": 5
+}