Skip to content

Commit

Permalink
update: wip
Browse files Browse the repository at this point in the history
  • Loading branch information
VsevolodX committed May 16, 2024
1 parent befc08d commit 78ac0f0
Show file tree
Hide file tree
Showing 2 changed files with 74 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,13 @@
" await install_packages(\"create_interface_with_min_strain_zsl.ipynb\", \"../../config.yml\")"
],
"metadata": {
"collapsed": false
"collapsed": false,
"ExecuteTime": {
"end_time": "2024-05-16T19:38:52.309620Z",
"start_time": "2024-05-16T19:38:52.304575Z"
}
},
"execution_count": null
"execution_count": 1
},
{
"cell_type": "markdown",
Expand All @@ -71,11 +75,28 @@
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"execution_count": 2,
"metadata": {
"ExecuteTime": {
"end_time": "2024-05-16T19:38:58.178616Z",
"start_time": "2024-05-16T19:38:52.440485Z"
}
},
"outputs": [
{
"ename": "ImportError",
"evalue": "cannot import name 'InterfaceSettings' from 'mat3ra.made.tools.build.interface' (/Users/mat3ra/code/GREEN/api-examples/.venv/lib/python3.11/site-packages/mat3ra/made/tools/build/interface.py)",
"output_type": "error",
"traceback": [
"\u001B[0;31m---------------------------------------------------------------------------\u001B[0m",
"\u001B[0;31mImportError\u001B[0m Traceback (most recent call last)",
"Cell \u001B[0;32mIn[2], line 1\u001B[0m\n\u001B[0;32m----> 1\u001B[0m \u001B[38;5;28;01mfrom\u001B[39;00m \u001B[38;5;21;01mmat3ra\u001B[39;00m\u001B[38;5;21;01m.\u001B[39;00m\u001B[38;5;21;01mmade\u001B[39;00m\u001B[38;5;21;01m.\u001B[39;00m\u001B[38;5;21;01mtools\u001B[39;00m\u001B[38;5;21;01m.\u001B[39;00m\u001B[38;5;21;01mbuild\u001B[39;00m\u001B[38;5;21;01m.\u001B[39;00m\u001B[38;5;21;01minterface\u001B[39;00m \u001B[38;5;28;01mimport\u001B[39;00m InterfaceSettings\n\u001B[1;32m 3\u001B[0m \u001B[38;5;66;03m# Parameters can be set during the class initialization:\u001B[39;00m\n\u001B[1;32m 4\u001B[0m interface_builder_settings \u001B[38;5;241m=\u001B[39m InterfaceSettings(\n\u001B[1;32m 5\u001B[0m distance_z\u001B[38;5;241m=\u001B[39m\u001B[38;5;241m3.0\u001B[39m, \u001B[38;5;66;03m# distance between substrate and layer, in Angstroms\u001B[39;00m\n\u001B[1;32m 6\u001B[0m use_conventional_cell\u001B[38;5;241m=\u001B[39m\u001B[38;5;28;01mTrue\u001B[39;00m, \u001B[38;5;66;03m# if True, the surface plane is constructed using miller indices of the conventional cell\u001B[39;00m\n\u001B[1;32m 7\u001B[0m )\n",
"\u001B[0;31mImportError\u001B[0m: cannot import name 'InterfaceSettings' from 'mat3ra.made.tools.build.interface' (/Users/mat3ra/code/GREEN/api-examples/.venv/lib/python3.11/site-packages/mat3ra/made/tools/build/interface.py)"
]
}
],
"source": [
"from mat3ra.made.tools.build.interface import InterfaceSettings\n",
"from mat3ra.made.tools.build.interface import InterfaceBuilderSettings\n",
"\n",
"# Parameters can be set during the class initialization:\n",
"interface_builder_settings = InterfaceSettings(\n",
Expand Down Expand Up @@ -176,6 +197,32 @@
},
"execution_count": null
},
{
"cell_type": "code",
"outputs": [],
"source": [
"from mat3ra.made.tools.build import create_interfaces\n",
"\n",
"default_interfaces = create_interfaces(materials[1], materials[1])"
],
"metadata": {
"collapsed": false
},
"execution_count": null
},
{
"cell_type": "code",
"outputs": [],
"source": [
"from utils.visualize import visualize_materials as visualize\n",
"default_interface = default_interfaces.get_interfaces_as_materials(0,(0,2))\n",
"visualize(default_interface, repetitions=[1, 1, 1], rotation=\"0x\")"
],
"metadata": {
"collapsed": false
},
"execution_count": null
},
{
"cell_type": "markdown",
"source": [
Expand Down
21 changes: 21 additions & 0 deletions utils/plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,24 @@ def plot_strain_vs_atoms(interface_data_holder: InterfaceDataHolder, settings: D

fig = go.Figure(data=data, layout=layout)
fig.show()


import plotly.graph_objs as go
from IPython.display import display
from plotly.subplots import make_subplots


def create_realtime_plot():
fig = make_subplots(rows=1, cols=1, specs=[[{"type": "scatter"}]])
scatter = go.Scatter(x=[], y=[], mode="lines+markers", name="Energy")
fig.add_trace(scatter)
fig.update_layout(title_text="Real-time Optimization Progress", xaxis_title="Step", yaxis_title="Energy (eV)")
f = go.FigureWidget(fig)
display(f)
return f


def update_plot(f, steps, energies):
with f.batch_update():
f.data[0].x = steps
f.data[0].y = energies

0 comments on commit 78ac0f0

Please sign in to comment.