Skip to content

Commit ba24c13

Browse files
authored
adding FAQ about save and load fitted medium (#45)
Adding FAQ about save and load fitted medium
1 parent f311e85 commit ba24c13

File tree

4 files changed

+62
-1
lines changed

4 files changed

+62
-1
lines changed
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
---
2+
title: How Can I Save and Load a Fitted Medium?
3+
date: 2025-09-16 12:38:02
4+
enabled: true
5+
category: "Mediums"
6+
---
7+
After fitting a medium, as described [here](https://docs.flexcompute.com/projects/tidy3d/en/stable/notebooks/Fitting.html){: .color-primary-hover}, it is possible to save the fitted medium as an hdf5 file and save time when using it in another model. To save the file, just use the `.to_file` method:
8+
9+
<div markdown class="code-snippet">
10+
{% highlight python %}
11+
fitted_medium.to_file('medium_name.hdf5')
12+
{% endhighlight %}
13+
{% include copy-button.html %}</div>
14+
15+
Now, the saved medium can be loaded with the [PoleResidue](https://docs.flexcompute.com/projects/tidy3d/en/latest/api/_autosummary/tidy3d.PoleResidue.html){: .color-primary-hover} `.from_file` method:
16+
17+
<div markdown class="code-snippet">
18+
{% highlight python %}
19+
loaded_medium = td.PoleResidue.from_file('medium_name.hdf5')
20+
{% endhighlight %}
21+
{% include copy-button.html %}</div>
22+
23+
To use this medium via the web GUI, you have two options:
24+
25+
(a): open the "Material Utilities", select the "Private Library", and click the "Upload Material" button;
26+
27+
(b): in the workbench, create a new medium and choose the "Import Material" option in the "Add Medium" panel.
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# How Can I Save and Load a Fitted Medium?
2+
3+
| Date | Category |
4+
|------------|-------------|
5+
| 2025-09-16 12:38:02 | Mediums |
6+
7+
8+
After fitting a medium, as described [here](https://docs.flexcompute.com/projects/tidy3d/en/stable/notebooks/Fitting.html), it is possible to save the fitted medium as an hdf5 file and save time when using it in another model. To save the file, just use the `.to_file` method:
9+
10+
11+
12+
```python
13+
fitted_medium.to_file('medium_name.hdf5')
14+
```
15+
16+
17+
18+
Now, the saved medium can be loaded with the [PoleResidue](https://docs.flexcompute.com/projects/tidy3d/en/latest/api/_autosummary/tidy3d.PoleResidue.html) `.from_file` method:
19+
20+
21+
22+
```python
23+
loaded_medium = td.PoleResidue.from_file('medium_name.hdf5')
24+
```
25+
26+
27+
28+
To use this medium via the web GUI, you have two options:
29+
30+
(a): open the "Material Utilities", select the "Private Library", and click the "Upload Material" button;
31+
32+
(b): in the workbench, create a new medium and choose the "Import Material" option in the "Add Medium" panel.

docs/mediums.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,4 @@ Mediums
1818
faq/how-can-i-define-a-2d-material.md
1919
faq/how-can-i-define-graphene.md
2020
faq/how-can-i-define-a-nonlinear-material.md
21+
faq/how-can-i-save-and-load-a-fitted-medium.md

faq_categories.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,8 @@
9090
"_faqs/how-do-i-load-a-commonly-used-dispersive-material.md",
9191
"_faqs/how-can-i-define-a-2d-material.md",
9292
"_faqs/how-can-i-define-graphene.md",
93-
"_faqs/how-can-i-define-a-nonlinear-material.md"
93+
"_faqs/how-can-i-define-a-nonlinear-material.md",
94+
"_faqs/how-can-i-save-and-load-a-fitted-medium.md"
9495
]
9596
},
9697
{

0 commit comments

Comments
 (0)