|
9 | 9 | # configure logging to show femmt terminal output |
10 | 10 | logging.basicConfig(format='%(levelname)s:%(message)s', level=logging.INFO) |
11 | 11 |
|
12 | | -def export_material2grid_example(): |
13 | | - """Get different material data example.""" |
| 12 | + |
| 13 | +def export_material2grid_example(plot: bool, save_to_txt: bool) -> None: |
| 14 | + """ |
| 15 | + Get different material data example. |
| 16 | +
|
| 17 | + :param plot: whether to plot or not |
| 18 | + :param save_to_txt: whether to save to txt file |
| 19 | + """ |
14 | 20 | # init a material database instance |
15 | 21 | mdb_data = mdb.Data() |
16 | 22 | path2grid_export = Path(get_user_paths().grid_export_data) |
17 | | - print(f"Data exported to {path2grid_export}") |
| 23 | + path2grid_plot = Path(get_user_paths().graphics) |
18 | 24 | material_name = mdb.Material.N49 |
19 | | - permeability_data_source = mdb.DataSource.LEA_MTB |
20 | | - permittivity_data_source = mdb.DataSource.LEA_MTB |
21 | 25 |
|
22 | 26 | # Permeability |
| 27 | + permeability_data_source = mdb.DataSource.LEA_MTB |
| 28 | + link2permeability_grid = path2grid_export.joinpath(f"{material_name.value}_{permeability_data_source.value}_permeability_grid.txt") |
| 29 | + link2permeability_plot = path2grid_plot.joinpath(f"{material_name.value}_{permeability_data_source.value}_permeability_grid.pdf") |
23 | 30 | permeability = mdb_data.get_complex_permeability(material=material_name, |
24 | 31 | data_source=permeability_data_source, |
25 | 32 | pv_fit_function=mdb.FitFunction.enhancedSteinmetz) |
26 | | - permeability.export_to_txt(path2grid_export.joinpath(f"{material_name.value}_{permeability_data_source.value}_permeability_grid.txt"), |
27 | | - frequencies=np.linspace(1e5, 1.5e6, 50), |
28 | | - temperatures=np.linspace(25, 70, 20), |
29 | | - b_vals=np.linspace(0, 0.2, 50)) |
30 | | - print(f"Exemplary complex permeability data: \n {permeability.measurement_data} \n") |
| 33 | + df_permeability_grid = permeability.to_grid(grid_frequency=np.linspace(1e5, 1.5e6, 50), |
| 34 | + grid_temperature=np.linspace(25, 70, 20), |
| 35 | + grid_flux_density=np.linspace(0, 0.2, 50), |
| 36 | + f_min_measurement=1e5, f_max_measurement=None, |
| 37 | + T_min_measurement=28, T_max_measurement=None, |
| 38 | + b_min_measurement=None, b_max_measurement=0.15) |
31 | 39 |
|
32 | 40 | # Permittivity |
| 41 | + permittivity_data_source = mdb.DataSource.LEA_MTB |
| 42 | + link2permittivity_grid = path2grid_export.joinpath(f"{material_name.value}_{permittivity_data_source.value}_permittivity_grid.txt") |
| 43 | + link2permittivity_plot = path2grid_plot.joinpath(f"{material_name.value}_{permittivity_data_source.value}_permittivity_grid.pdf") |
33 | 44 | permittivity = mdb_data.get_complex_permittivity(material=material_name, |
34 | 45 | data_source=permittivity_data_source) |
35 | | - permittivity.export_to_txt(path2grid_export.joinpath(f"{material_name.value}_{permittivity_data_source.value}_permittivity_grid.txt"), |
36 | | - frequencies=np.linspace(1e5, 1.5e6, 50), |
37 | | - temperatures=np.linspace(25, 70, 20)) |
38 | | - print(f"Exemplary complex permittivity data: \n {permittivity.measurement_data} \n ") |
| 46 | + df_permittivity_grid = permittivity.to_grid(grid_frequency=np.linspace(1e5, 1.5e6, 50), |
| 47 | + grid_temperature=np.linspace(25, 70, 20)) |
| 48 | + |
| 49 | + if plot: |
| 50 | + permeability.plot_grid(df_permeability_grid, |
| 51 | + save_path=link2permeability_plot, |
| 52 | + temps=[25], |
| 53 | + no_levels=20, |
| 54 | + f_min=0.95e5, f_max=1.05e6, |
| 55 | + b_min=20e-3, b_max=105e-3) |
| 56 | + permittivity.plot_grid(df_permittivity_grid, |
| 57 | + no_levels=20, |
| 58 | + save_path=link2permittivity_plot, |
| 59 | + f_min=0.95e5, f_max=1.05e6) |
| 60 | + |
| 61 | + if save_to_txt: |
| 62 | + permeability.grid2txt(df_permeability_grid, link2permeability_grid) |
| 63 | + permittivity.grid2txt(df_permittivity_grid, link2permittivity_grid) |
| 64 | + print(f"Data exported to {path2grid_export}") |
39 | 65 |
|
40 | 66 |
|
41 | 67 | if __name__ == '__main__': |
42 | | - export_material2grid_example() |
| 68 | + export_material2grid_example(plot=True, save_to_txt=True) |
0 commit comments