pyfemtet 0.4.6__tar.gz → 0.4.7__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of pyfemtet might be problematic. Click here for more details.

Files changed (80) hide show
  1. {pyfemtet-0.4.6 → pyfemtet-0.4.7}/PKG-INFO +2 -1
  2. pyfemtet-0.4.7/pyfemtet/__init__.py +1 -0
  3. pyfemtet-0.4.7/pyfemtet/_test_util.py +95 -0
  4. {pyfemtet-0.4.6 → pyfemtet-0.4.7}/pyfemtet/opt/_femopt.py +7 -1
  5. pyfemtet-0.4.7/pyfemtet/opt/femprj_sample/cad_ex01_NX_test_result.reccsv +13 -0
  6. pyfemtet-0.4.7/pyfemtet/opt/femprj_sample/cad_ex01_SW_test_result.reccsv +13 -0
  7. {pyfemtet-0.4.6 → pyfemtet-0.4.7}/pyfemtet/opt/femprj_sample/gal_ex58_parametric.femprj +0 -0
  8. pyfemtet-0.4.7/pyfemtet/opt/femprj_sample/gal_ex58_parametric_test_result.reccsv +13 -0
  9. pyfemtet-0.4.7/pyfemtet/opt/femprj_sample/gau_ex08_parametric_test_result.reccsv +23 -0
  10. pyfemtet-0.4.7/pyfemtet/opt/femprj_sample/her_ex40_parametric_test_result.reccsv +18 -0
  11. pyfemtet-0.4.7/pyfemtet/opt/femprj_sample/paswat_ex1_parametric_test_result.reccsv +18 -0
  12. pyfemtet-0.4.7/pyfemtet/opt/femprj_sample/wat_ex14_parametric_test_result.reccsv +18 -0
  13. {pyfemtet-0.4.6 → pyfemtet-0.4.7}/pyfemtet/opt/femprj_sample_jp/gal_ex58_parametric_jp.femprj +0 -0
  14. {pyfemtet-0.4.6 → pyfemtet-0.4.7}/pyfemtet/opt/interface/_femtet.py +45 -9
  15. {pyfemtet-0.4.6 → pyfemtet-0.4.7}/pyfemtet/opt/interface/_femtet_parametric.py +3 -3
  16. {pyfemtet-0.4.6 → pyfemtet-0.4.7}/pyfemtet/opt/visualization/_graphs.py +6 -0
  17. {pyfemtet-0.4.6 → pyfemtet-0.4.7}/pyproject.toml +2 -2
  18. pyfemtet-0.4.6/pyfemtet/__init__.py +0 -1
  19. {pyfemtet-0.4.6 → pyfemtet-0.4.7}/LICENSE +0 -0
  20. {pyfemtet-0.4.6 → pyfemtet-0.4.7}/README.md +0 -0
  21. {pyfemtet-0.4.6 → pyfemtet-0.4.7}/pyfemtet/FemtetPJTSample/NX_ex01/NX_ex01.femprj +0 -0
  22. {pyfemtet-0.4.6 → pyfemtet-0.4.7}/pyfemtet/FemtetPJTSample/NX_ex01/NX_ex01.prt +0 -0
  23. {pyfemtet-0.4.6 → pyfemtet-0.4.7}/pyfemtet/FemtetPJTSample/NX_ex01/NX_ex01.py +0 -0
  24. {pyfemtet-0.4.6 → pyfemtet-0.4.7}/pyfemtet/FemtetPJTSample/Sldworks_ex01/Sldworks_ex01.SLDPRT +0 -0
  25. {pyfemtet-0.4.6 → pyfemtet-0.4.7}/pyfemtet/FemtetPJTSample/Sldworks_ex01/Sldworks_ex01.femprj +0 -0
  26. {pyfemtet-0.4.6 → pyfemtet-0.4.7}/pyfemtet/FemtetPJTSample/Sldworks_ex01/Sldworks_ex01.py +0 -0
  27. {pyfemtet-0.4.6 → pyfemtet-0.4.7}/pyfemtet/FemtetPJTSample/_her_ex40_parametric.py +0 -0
  28. {pyfemtet-0.4.6 → pyfemtet-0.4.7}/pyfemtet/FemtetPJTSample/gau_ex08_parametric.femprj +0 -0
  29. {pyfemtet-0.4.6 → pyfemtet-0.4.7}/pyfemtet/FemtetPJTSample/gau_ex08_parametric.py +0 -0
  30. {pyfemtet-0.4.6 → pyfemtet-0.4.7}/pyfemtet/FemtetPJTSample/her_ex40_parametric.femprj +0 -0
  31. {pyfemtet-0.4.6 → pyfemtet-0.4.7}/pyfemtet/FemtetPJTSample/her_ex40_parametric.py +0 -0
  32. {pyfemtet-0.4.6 → pyfemtet-0.4.7}/pyfemtet/FemtetPJTSample/wat_ex14_parallel_parametric.py +0 -0
  33. {pyfemtet-0.4.6 → pyfemtet-0.4.7}/pyfemtet/FemtetPJTSample/wat_ex14_parametric.femprj +0 -0
  34. {pyfemtet-0.4.6 → pyfemtet-0.4.7}/pyfemtet/FemtetPJTSample/wat_ex14_parametric.py +0 -0
  35. {pyfemtet-0.4.6 → pyfemtet-0.4.7}/pyfemtet/core.py +0 -0
  36. {pyfemtet-0.4.6 → pyfemtet-0.4.7}/pyfemtet/dispatch_extensions.py +0 -0
  37. {pyfemtet-0.4.6 → pyfemtet-0.4.7}/pyfemtet/logger.py +0 -0
  38. {pyfemtet-0.4.6 → pyfemtet-0.4.7}/pyfemtet/opt/__init__.py +0 -0
  39. {pyfemtet-0.4.6 → pyfemtet-0.4.7}/pyfemtet/opt/_femopt_core.py +0 -0
  40. {pyfemtet-0.4.6 → pyfemtet-0.4.7}/pyfemtet/opt/femprj_sample/cad_ex01_NX.femprj +0 -0
  41. {pyfemtet-0.4.6 → pyfemtet-0.4.7}/pyfemtet/opt/femprj_sample/cad_ex01_NX.prt +0 -0
  42. {pyfemtet-0.4.6 → pyfemtet-0.4.7}/pyfemtet/opt/femprj_sample/cad_ex01_NX.py +0 -0
  43. {pyfemtet-0.4.6 → pyfemtet-0.4.7}/pyfemtet/opt/femprj_sample/cad_ex01_SW.SLDPRT +0 -0
  44. {pyfemtet-0.4.6 → pyfemtet-0.4.7}/pyfemtet/opt/femprj_sample/cad_ex01_SW.femprj +0 -0
  45. {pyfemtet-0.4.6 → pyfemtet-0.4.7}/pyfemtet/opt/femprj_sample/cad_ex01_SW.py +0 -0
  46. {pyfemtet-0.4.6 → pyfemtet-0.4.7}/pyfemtet/opt/femprj_sample/gal_ex58_parametric.py +0 -0
  47. {pyfemtet-0.4.6 → pyfemtet-0.4.7}/pyfemtet/opt/femprj_sample/gau_ex08_parametric.femprj +0 -0
  48. {pyfemtet-0.4.6 → pyfemtet-0.4.7}/pyfemtet/opt/femprj_sample/gau_ex08_parametric.py +0 -0
  49. {pyfemtet-0.4.6 → pyfemtet-0.4.7}/pyfemtet/opt/femprj_sample/her_ex40_parametric.femprj +0 -0
  50. {pyfemtet-0.4.6 → pyfemtet-0.4.7}/pyfemtet/opt/femprj_sample/her_ex40_parametric.py +0 -0
  51. {pyfemtet-0.4.6 → pyfemtet-0.4.7}/pyfemtet/opt/femprj_sample/paswat_ex1_parametric.femprj +0 -0
  52. {pyfemtet-0.4.6 → pyfemtet-0.4.7}/pyfemtet/opt/femprj_sample/paswat_ex1_parametric.py +0 -0
  53. {pyfemtet-0.4.6 → pyfemtet-0.4.7}/pyfemtet/opt/femprj_sample/paswat_ex1_parametric_parallel.py +0 -0
  54. {pyfemtet-0.4.6 → pyfemtet-0.4.7}/pyfemtet/opt/femprj_sample/wat_ex14_parametric.femprj +0 -0
  55. {pyfemtet-0.4.6 → pyfemtet-0.4.7}/pyfemtet/opt/femprj_sample/wat_ex14_parametric.py +0 -0
  56. {pyfemtet-0.4.6 → pyfemtet-0.4.7}/pyfemtet/opt/femprj_sample_jp/cad_ex01_NX_jp.femprj +0 -0
  57. {pyfemtet-0.4.6 → pyfemtet-0.4.7}/pyfemtet/opt/femprj_sample_jp/cad_ex01_NX_jp.py +0 -0
  58. {pyfemtet-0.4.6 → pyfemtet-0.4.7}/pyfemtet/opt/femprj_sample_jp/cad_ex01_SW_jp.femprj +0 -0
  59. {pyfemtet-0.4.6 → pyfemtet-0.4.7}/pyfemtet/opt/femprj_sample_jp/cad_ex01_SW_jp.py +0 -0
  60. {pyfemtet-0.4.6 → pyfemtet-0.4.7}/pyfemtet/opt/femprj_sample_jp/gal_ex58_parametric_jp.py +0 -0
  61. {pyfemtet-0.4.6 → pyfemtet-0.4.7}/pyfemtet/opt/femprj_sample_jp/gau_ex08_parametric_jp.femprj +0 -0
  62. {pyfemtet-0.4.6 → pyfemtet-0.4.7}/pyfemtet/opt/femprj_sample_jp/gau_ex08_parametric_jp.py +0 -0
  63. {pyfemtet-0.4.6 → pyfemtet-0.4.7}/pyfemtet/opt/femprj_sample_jp/her_ex40_parametric_jp.femprj +0 -0
  64. {pyfemtet-0.4.6 → pyfemtet-0.4.7}/pyfemtet/opt/femprj_sample_jp/her_ex40_parametric_jp.py +0 -0
  65. {pyfemtet-0.4.6 → pyfemtet-0.4.7}/pyfemtet/opt/femprj_sample_jp/paswat_ex1_parametric_jp.femprj +0 -0
  66. {pyfemtet-0.4.6 → pyfemtet-0.4.7}/pyfemtet/opt/femprj_sample_jp/paswat_ex1_parametric_jp.py +0 -0
  67. {pyfemtet-0.4.6 → pyfemtet-0.4.7}/pyfemtet/opt/femprj_sample_jp/paswat_ex1_parametric_parallel_jp.py +0 -0
  68. {pyfemtet-0.4.6 → pyfemtet-0.4.7}/pyfemtet/opt/femprj_sample_jp/wat_ex14_parametric_jp.femprj +0 -0
  69. {pyfemtet-0.4.6 → pyfemtet-0.4.7}/pyfemtet/opt/femprj_sample_jp/wat_ex14_parametric_jp.py +0 -0
  70. {pyfemtet-0.4.6 → pyfemtet-0.4.7}/pyfemtet/opt/interface/__init__.py +0 -0
  71. {pyfemtet-0.4.6 → pyfemtet-0.4.7}/pyfemtet/opt/interface/_base.py +0 -0
  72. {pyfemtet-0.4.6 → pyfemtet-0.4.7}/pyfemtet/opt/interface/_femtet_with_nx/__init__.py +0 -0
  73. {pyfemtet-0.4.6 → pyfemtet-0.4.7}/pyfemtet/opt/interface/_femtet_with_nx/_interface.py +0 -0
  74. {pyfemtet-0.4.6 → pyfemtet-0.4.7}/pyfemtet/opt/interface/_femtet_with_nx/update_model.py +0 -0
  75. {pyfemtet-0.4.6 → pyfemtet-0.4.7}/pyfemtet/opt/interface/_femtet_with_sldworks.py +0 -0
  76. {pyfemtet-0.4.6 → pyfemtet-0.4.7}/pyfemtet/opt/opt/__init__.py +0 -0
  77. {pyfemtet-0.4.6 → pyfemtet-0.4.7}/pyfemtet/opt/opt/_base.py +0 -0
  78. {pyfemtet-0.4.6 → pyfemtet-0.4.7}/pyfemtet/opt/opt/_optuna.py +0 -0
  79. {pyfemtet-0.4.6 → pyfemtet-0.4.7}/pyfemtet/opt/visualization/__init__.py +0 -0
  80. {pyfemtet-0.4.6 → pyfemtet-0.4.7}/pyfemtet/opt/visualization/_monitor.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: pyfemtet
3
- Version: 0.4.6
3
+ Version: 0.4.7
4
4
  Summary: Design parameter optimization using Femtet.
5
5
  Home-page: https://github.com/pyfemtet/pyfemtet
6
6
  License: BSD-3-Clause
@@ -27,6 +27,7 @@ Requires-Dist: optuna-integration (>=3.6.0,<4.0.0)
27
27
  Requires-Dist: pandas (>=2.1.3,<3.0.0)
28
28
  Requires-Dist: plotly (>=5.18.0,<6.0.0)
29
29
  Requires-Dist: psutil (>=5.9.6,<6.0.0)
30
+ Requires-Dist: pytest-dashboard (>=0.1.2,<0.2.0)
30
31
  Requires-Dist: pywin32 (>=306,<307)
31
32
  Requires-Dist: scipy (>=1.11.4,<2.0.0)
32
33
  Requires-Dist: tqdm (>=4.66.1,<5.0.0)
@@ -0,0 +1 @@
1
+ __version__ = "0.4.7"
@@ -0,0 +1,95 @@
1
+ import os
2
+ import csv
3
+ from shutil import copy
4
+ from time import sleep
5
+ from subprocess import run
6
+ from multiprocessing import Process
7
+ from glob import glob
8
+
9
+ import numpy as np
10
+ import pandas as pd
11
+ from tqdm import tqdm
12
+ from win32com.client import Dispatch
13
+ from femtetutils import util
14
+
15
+ from pyfemtet.opt import FEMOpt
16
+
17
+
18
+ def _open_femprj(femprj_path):
19
+ Femtet = Dispatch('FemtetMacro.Femtet')
20
+ for _ in tqdm(range(5), 'wait for dispatch Femtet'):
21
+ sleep(1)
22
+ Femtet.LoadProject(femprj_path, True)
23
+
24
+
25
+ def launch_femtet(femprj_path):
26
+ # launch Femtet externally
27
+ print('Launching Femtet...')
28
+ util.execute_femtet()
29
+ pid = util.get_last_executed_femtet_process_id()
30
+ for _ in tqdm(range(8), 'Wait for launch Femtet.'):
31
+ sleep(1)
32
+
33
+ # open femprj in a different process
34
+ # to release Femtet for sample program
35
+ print('Opening femprj...')
36
+ p = Process(
37
+ target=_open_femprj,
38
+ args=(femprj_path,),
39
+ )
40
+ p.start()
41
+ p.join()
42
+
43
+
44
+ def taskkill_femtet():
45
+ for _ in tqdm(range(3), 'wait before taskkill Femtet'):
46
+ sleep(1)
47
+ run(['taskkill', '/f', '/im', 'Femtet.exe'])
48
+ for _ in tqdm(range(3), 'wait after taskkill Femtet'):
49
+ sleep(1)
50
+
51
+
52
+ def find_latest_csv(dir_path=None):
53
+ if dir_path is None: dir_path = '.'
54
+ target = os.path.join(dir_path, '*.csv')
55
+ files = [(f, os.path.getmtime(f)) for f in glob(target)]
56
+ out = sorted(files, key=lambda files: files[1])[-1]
57
+ return os.path.abspath(out[0])
58
+
59
+
60
+ def py_to_reccsv(py_path, suffix=''):
61
+ dst_csv_path = py_path + suffix
62
+ dst_csv_path = dst_csv_path.replace(f'.py{suffix}', f'{suffix}.reccsv')
63
+ return dst_csv_path
64
+
65
+
66
+ def record_result(src: FEMOpt or str, py_path, suffix=''):
67
+ """Record the result csv for `is_equal_result`."""
68
+
69
+ if isinstance(src, FEMOpt): # get df directory
70
+ src_csv_path = src.history_path
71
+ else:
72
+ src_csv_path = os.path.abspath(src)
73
+
74
+ dst_csv_path = py_to_reccsv(py_path, suffix)
75
+ copy(src_csv_path, dst_csv_path)
76
+
77
+
78
+ def _get_obj_from_csv(csv_path):
79
+ df = pd.read_csv(csv_path, encoding='cp932', header=2)
80
+ columns = df.columns
81
+ with open(csv_path, mode='r', encoding='cp932', newline='\n') as f:
82
+ reader = csv.reader(f, delimiter=',')
83
+ meta = reader.__next__()
84
+ obj_indices = np.where(np.array(meta) == 'obj')[0]
85
+ out = df.iloc[:, obj_indices]
86
+ return out, columns
87
+
88
+
89
+ def is_equal_result(csv1, csv2):
90
+ """Check the equality of two result csv files."""
91
+ df1, columns1 = _get_obj_from_csv(csv1)
92
+ df2, columns2 = _get_obj_from_csv(csv2)
93
+ assert len(columns1) == len(columns2), '結果 csv の column 数が異なります。'
94
+ assert len(df1) == len(df2), '結果 csv の row 数が異なります。'
95
+ assert (np.abs(df1.values - df2.values) / np.abs(df2.values)).max() <= 0.01, '前回の結果と 1% を超える相違があります。'
@@ -383,7 +383,13 @@ class FEMOpt:
383
383
  # Femtet の parametric 設定を目的関数に用いるかどうか
384
384
  if self.fem.parametric_output_indexes_use_as_objective is not None:
385
385
  from pyfemtet.opt.interface._femtet_parametric import add_parametric_results_as_objectives
386
- add_parametric_results_as_objectives(self, self.fem.parametric_output_indexes_use_as_objective)
386
+ indexes = list(self.fem.parametric_output_indexes_use_as_objective.keys())
387
+ directions = list(self.fem.parametric_output_indexes_use_as_objective.values())
388
+ add_parametric_results_as_objectives(
389
+ self,
390
+ indexes,
391
+ directions,
392
+ )
387
393
 
388
394
  # actor の設定
389
395
  self.status = OptimizationStatus(self.client)
@@ -0,0 +1,13 @@
1
+ "{""femprj_path"": null, ""model_name"": ""ex58_UnLoad""}",prm,obj,obj_direction,,,,,
2
+ ,,,,,,,,
3
+ trial,rot,final angle (degree),final angle (degree)_direction,non_domi,feasible,hypervolume,message,time
4
+ 1,90.0,81.62540665669353,90,False,True,-1.0,initial,2024-06-11 12:19:15.494862
5
+ 2,87.49080237694724,79.02571752958842,90,False,True,-1.0,,2024-06-11 12:19:19.728891
6
+ 3,99.01428612819832,90.96145916607887,90,False,True,-1.0,,2024-06-11 12:19:23.959099
7
+ 4,99.99999999999999,91.89033160850725,90,False,True,-1.0,,2024-06-11 12:19:29.210094
8
+ 5,96.7613593526426,88.77003517126444,90,False,True,-1.0,,2024-06-11 12:19:33.556167
9
+ 6,80.0,71.5309188581146,90,False,True,-1.0,,2024-06-11 12:19:37.894866
10
+ 7,97.45535890878755,89.47178515828678,90,False,True,-1.0,,2024-06-11 12:19:42.314653
11
+ 8,96.18747750627301,88.19831186499154,90,False,True,-1.0,,2024-06-11 12:19:46.867626
12
+ 9,98.14241558949382,90.13165212114446,90,False,True,-1.0,,2024-06-11 12:19:51.352111
13
+ 10,98.08002450883177,90.07026771243692,90,True,True,-1.0,,2024-06-11 12:19:55.861780
@@ -0,0 +1,13 @@
1
+ "{""femprj_path"": null, ""model_name"": ""ex58_UnLoad""}",prm,obj,obj_direction,,,,,
2
+ ,,,,,,,,
3
+ trial,rot,final angle (degree),final angle (degree)_direction,non_domi,feasible,hypervolume,message,time
4
+ 1,90.0,81.62540665669353,90,False,True,-1.0,initial,2024-06-11 12:19:15.494862
5
+ 2,87.49080237694724,79.02571752958842,90,False,True,-1.0,,2024-06-11 12:19:19.728891
6
+ 3,99.01428612819832,90.96145916607887,90,False,True,-1.0,,2024-06-11 12:19:23.959099
7
+ 4,99.99999999999999,91.89033160850725,90,False,True,-1.0,,2024-06-11 12:19:29.210094
8
+ 5,96.7613593526426,88.77003517126444,90,False,True,-1.0,,2024-06-11 12:19:33.556167
9
+ 6,80.0,71.5309188581146,90,False,True,-1.0,,2024-06-11 12:19:37.894866
10
+ 7,97.45535890878755,89.47178515828678,90,False,True,-1.0,,2024-06-11 12:19:42.314653
11
+ 8,96.18747750627301,88.19831186499154,90,False,True,-1.0,,2024-06-11 12:19:46.867626
12
+ 9,98.14241558949382,90.13165212114446,90,False,True,-1.0,,2024-06-11 12:19:51.352111
13
+ 10,98.08002450883177,90.07026771243692,90,True,True,-1.0,,2024-06-11 12:19:55.861780
@@ -0,0 +1,13 @@
1
+ "{""femprj_path"": null, ""model_name"": ""ex58_UnLoad""}",prm,obj,obj_direction,,,,,
2
+ ,,,,,,,,
3
+ trial,rot,final angle (degree),final angle (degree)_direction,non_domi,feasible,hypervolume,message,time
4
+ 1,90.0,81.62540665669353,90,False,True,-1.0,initial,2024-06-11 12:19:15.494862
5
+ 2,87.49080237694724,79.02571752958842,90,False,True,-1.0,,2024-06-11 12:19:19.728891
6
+ 3,99.01428612819832,90.96145916607887,90,False,True,-1.0,,2024-06-11 12:19:23.959099
7
+ 4,99.99999999999999,91.89033160850725,90,False,True,-1.0,,2024-06-11 12:19:29.210094
8
+ 5,96.7613593526426,88.77003517126444,90,False,True,-1.0,,2024-06-11 12:19:33.556167
9
+ 6,80.0,71.5309188581146,90,False,True,-1.0,,2024-06-11 12:19:37.894866
10
+ 7,97.45535890878755,89.47178515828678,90,False,True,-1.0,,2024-06-11 12:19:42.314653
11
+ 8,96.18747750627301,88.19831186499154,90,False,True,-1.0,,2024-06-11 12:19:46.867626
12
+ 9,98.14241558949382,90.13165212114446,90,False,True,-1.0,,2024-06-11 12:19:51.352111
13
+ 10,98.08002450883177,90.07026771243692,90,True,True,-1.0,,2024-06-11 12:19:55.861780
@@ -0,0 +1,23 @@
1
+ "{""femprj_path"": null, ""model_name"": ""ex8""}",prm,prm,prm,obj,obj_direction,,,,,
2
+ ,,,,,,,,,,
3
+ trial,helical_pitch,coil_radius,n_turns,self-inductance (F),self-inductance (F)_direction,non_domi,feasible,hypervolume,message,time
4
+ 1,6.0,10.0,5.0,2.2519131001598675e-07,1e-07,False,True,-1.0,initial,2024-06-11 12:02:57.767918
5
+ 2,5.623252451619978,9.556428757689245,3.9279757672456204,1.5669600588107823e-07,1e-07,False,True,-1.0,,2024-06-11 12:03:01.879689
6
+ 3,4.420717726239158,8.795585311974417,3.404460046972835,1.2486865567061983e-07,1e-07,False,True,-1.0,,2024-06-11 12:03:06.695218
7
+ 4,6.890675795624973,1.185260448662222,4.879639408647977,1.1068853339253005e-08,1e-07,False,True,-1.0,,2024-06-11 12:03:09.810784
8
+ 5,7.363282035041603,2.9110519961044856,1.7272998688284025,5.928345320407693e-09,1e-07,False,True,-1.0,,2024-06-11 12:03:12.620381
9
+ 6,4.506659276939239,8.848248131255941,3.3689827006547204,1.223080407315596e-07,1e-07,False,True,-1.0,,2024-06-11 12:03:21.984837
10
+ 7,4.766513095940718,9.009910692888063,3.2031623183171014,1.1395898205496435e-07,1e-07,False,True,-1.0,,2024-06-11 12:03:25.935771
11
+ 8,4.952240014062343,9.147228346475954,2.923015991988623,1.0163581024783297e-07,1e-07,False,True,-1.0,,2024-06-11 12:03:29.971566
12
+ 9,5.066580537443571,9.328659775516126,2.415616268398396,7.9346679307476e-08,1e-07,False,True,-1.0,,2024-06-11 12:03:33.843674
13
+ 10,5.01255047733164,9.185738480635885,2.8492684510814064,9.909738207022439e-08,1e-07,False,True,-1.0,,2024-06-11 12:03:38.301538
14
+ 11,5.00852993138919,9.181676469148485,2.8487833409683856,9.932809365733774e-08,1e-07,False,True,-1.0,,2024-06-11 12:03:42.927279
15
+ 12,5.015372908010907,9.156507516160001,2.84363953399497,9.865521830979344e-08,1e-07,False,True,-1.0,,2024-06-11 12:03:47.695209
16
+ 13,4.936583250613616,9.643690440100311,2.8584657253663925,1.101940126271035e-07,1e-07,False,True,-1.0,,2024-06-11 12:03:52.718947
17
+ 14,5.102945083594629,8.690025958818417,2.845587386493274,8.937388292289982e-08,1e-07,False,True,-1.0,,2024-06-11 12:03:58.135407
18
+ 15,4.991284994799307,9.188650804778193,2.8530392301069725,9.970815493825604e-08,1e-07,False,True,-1.0,,2024-06-11 12:04:05.138794
19
+ 16,4.798136039813497,9.176815614734876,2.8229449492498473,9.890481643260465e-08,1e-07,False,True,-1.0,,2024-06-11 12:04:14.148550
20
+ 17,4.930367618092964,9.199092260972836,2.8443627311061546,9.98421974076081e-08,1e-07,True,True,-1.0,,2024-06-11 12:04:28.793111
21
+ 18,4.917692804276215,9.210004097072988,2.8402049456555583,1.0026551790777177e-07,1e-07,False,True,-1.0,,2024-06-11 12:04:53.890898
22
+ 19,4.916044853968383,9.214647159558751,2.839933299380106,9.881932615643327e-08,1e-07,False,True,-1.0,,2024-06-11 12:05:39.178010
23
+ 20,4.924334850336223,9.19023089875423,2.8409787839543563,9.883080340842676e-08,1e-07,False,True,-1.0,,2024-06-11 12:07:03.669665
@@ -0,0 +1,18 @@
1
+ "{""femprj_path"": null, ""model_name"": ""Harm""}",prm,prm,prm,obj,obj_direction,,cns,cns_lb,cns_ub,cns,cns_lb,cns_ub,,,,
2
+ ,,,,,,,,,,,,,,,,
3
+ trial,antenna_radius,substrate_w,port_x,first resonant frequency(Hz),first resonant frequency(Hz)_direction,non_domi,antenna and substrate clearance,antenna and substrate clearance_lower_bound,antenna and substrate clearance_upper_bound,antenna and port clearance,antenna and port clearance_lower_bound,antenna and port clearance_upper_bound,feasible,hypervolume,message,time
4
+ 1,10.0,50.0,5.0,4289000000.0,3000000000.0,False,15.0,1,,5.0,1,,True,-1.0,initial,2024-06-11 12:08:26.664402
5
+ 2,13.979877262955549,43.12037280884873,3.96389588638785,3050000000.0,3000000000.0,False,7.580309099999999,1,,10.01598141,1,,True,-1.0,,2024-06-11 12:08:45.888336
6
+ 3,17.48663961200633,44.246782213565524,4.4546743769349115,2460000000.0,3000000000.0,False,4.636751499999999,1,,13.03196522,1,,True,-1.0,,2024-06-11 12:09:08.898036
7
+ 4,11.841049763255539,55.70351922786027,4.793801861008835,3581000000.0,3000000000.0,False,16.0107098,1,,7.04724794,1,,True,-1.0,,2024-06-11 12:09:30.818053
8
+ 5,12.713516576204174,51.84829137724085,1.8825578416799567,2932000000.0,3000000000.0,False,13.2106291,1,,10.83095876,1,,True,-1.0,,2024-06-11 12:09:46.800326
9
+ 6,14.113172778521575,43.41048247374583,2.235980266720311,2991000000.0,3000000000.0,True,7.592068450000001,1,,11.877192529999999,1,,True,-1.0,,2024-06-11 12:10:06.872645
10
+ 7,19.233283058799998,59.31264066149119,16.35954961421276,2283000000.0,3000000000.0,False,10.42303725,1,,2.8737335,1,,True,-1.0,,2024-06-11 12:10:40.123116
11
+ 8,11.60228740609402,42.44076469689558,10.408361292114133,3758000000.0,3000000000.0,False,9.618094950000001,1,,1.1939261000000005,1,,True,-1.0,,2024-06-11 12:11:03.207759
12
+ 9,14.93783426530973,46.23422152178822,10.881292402378406,2932000000.0,3000000000.0,False,8.179276449999998,1,,4.056541900000001,1,,True,-1.0,,2024-06-11 12:11:30.548731
13
+ 10,13.968499682166277,58.437484700462335,2.6813575389864703,2991000000.0,3000000000.0,True,15.250242649999999,1,,11.28714216,1,,True,-1.0,,2024-06-11 12:11:50.050599
14
+ 11,14.54315734982604,52.537550133941885,1.0,2932000000.0,3000000000.0,False,11.725617749999998,1,,13.5431573,1,,True,-1.0,,2024-06-11 12:12:12.701262
15
+ 12,14.586861208706766,59.99999999999999,5.909396621050475,2932000000.0,3000000000.0,False,15.4131388,1,,8.677464579999999,1,,True,-1.0,,2024-06-11 12:12:34.168326
16
+ 13,14.706782700305354,40.0,1.0,2814000000.0,3000000000.0,False,5.2932173,1,,13.7067827,1,,True,-1.0,,2024-06-11 12:13:37.839853
17
+ 14,14.43570684403354,51.141218169528905,5.404811972123167,2932000000.0,3000000000.0,False,11.134902299999998,1,,9.030894830000001,1,,True,-1.0,,2024-06-11 12:14:39.583756
18
+ 15,14.458054466363947,59.99999999999999,1.0,2932000000.0,3000000000.0,False,15.5419455,1,,13.4580545,1,,True,-1.0,,2024-06-11 12:14:58.872749
@@ -0,0 +1,18 @@
1
+ "{""femprj_path"": null, ""model_name"": ""Ex1""}",prm,prm,prm,obj,obj_direction,obj,obj_direction,obj,obj_direction,,,,,
2
+ ,,,,,,,,,,,,,,
3
+ trial,substrate_w,substrate_d,rot,max temp. of<br>MAINCHIP (degree),max temp. of<br>MAINCHIP (degree)_direction,max temp. of<br>SUBCHIP (degree),max temp. of<br>SUBCHIP (degree)_direction,substrate size (mm2),substrate size (mm2)_direction,non_domi,feasible,hypervolume,message,time
4
+ 1,40.0,60.0,0.0,33.67695768582703,minimize,33.95371403110336,minimize,2400.0,minimize,True,True,0.0,initial,2024-06-11 12:17:25.110141
5
+ 2,36.232524516199774,58.71857196665782,131.75890952605292,36.750613396557995,minimize,35.98760273557258,minimize,2127.522098595014,minimize,False,True,0.0,,2024-06-11 12:17:29.371084
6
+ 3,44.74902239948739,38.05648465150335,28.079013660516477,37.661215802334205,minimize,37.688375728423864,minimize,1702.9904863055572,minimize,False,True,0.0,,2024-06-11 12:17:33.564289
7
+ 4,24.20717726239158,56.52057979014832,108.20070211377758,38.03360975542378,minimize,37.132207739036424,minimize,1368.2036963173987,minimize,False,True,0.0,,2024-06-11 12:17:37.853520
8
+ 5,48.90675795624973,34.53519685169086,174.58377338915898,35.8008561699603,minimize,35.41803365231452,minimize,1689.0045172706505,minimize,True,True,1.8564481859818923e-05,,2024-06-11 12:17:41.999764
9
+ 6,53.632820350416026,39.520816877635184,32.72849409727811,36.27586854489045,minimize,36.24746978400414,minimize,2119.612874858985,minimize,False,True,1.8564481859818923e-05,,2024-06-11 12:17:46.239353
10
+ 7,28.969371374430487,41.91029831694798,94.45615769380281,37.30507756114715,minimize,37.03664336271842,minimize,1214.1149969374887,minimize,True,True,0.0004588839992990786,,2024-06-11 12:17:50.385009
11
+ 8,38.413910708400394,41.57195764514909,110.1335210500283,37.576825749490744,minimize,37.23183262975933,minimize,1596.9414668705863,minimize,False,True,0.0004588839992990786,,2024-06-11 12:17:54.833608
12
+ 9,27.30076670477759,41.59576086191567,65.9451317928645,40.3319296385719,minimize,40.398458177958574,minimize,1135.596164039882,minimize,True,True,0.000640516961074097,,2024-06-11 12:17:59.016440
13
+ 10,39.33065940024737,54.41457499621835,35.941280788504756,36.33478914713188,minimize,36.42436238628697,minimize,2140.161115720755,minimize,False,True,0.000640516961074097,,2024-06-11 12:18:03.281085
14
+ 11,29.88951598161767,48.530123354694155,153.62497867846213,39.42958363258689,minimize,38.57020860420411,minimize,1450.5418998462744,minimize,False,True,0.000640516961074097,,2024-06-11 12:18:07.538199
15
+ 12,31.485762571965203,47.06581165954471,80.23637941165202,36.63056881181441,minimize,36.53774341292369,minimize,1481.9029737625024,minimize,True,True,0.0006405332168774407,,2024-06-11 12:18:11.814563
16
+ 13,22.592602387021333,51.59088187331228,6.2020220936995525,40.387965035487035,minimize,40.85943258832127,minimize,1165.5722822320565,minimize,False,True,0.0006405332168774407,,2024-06-11 12:18:16.222971
17
+ 14,58.76493724495243,44.20401050976337,64.09642020029887,34.858239533999296,minimize,34.725797147945734,minimize,2597.645901020641,minimize,False,True,0.0006405332168774407,,2024-06-11 12:18:20.540597
18
+ 15,32.86246372091377,44.383694428619314,102.63175919113127,37.1577717589319,minimize,36.7308460274431,minimize,1458.5575460918933,minimize,True,True,0.0006704802815873576,,2024-06-11 12:18:24.780506
@@ -0,0 +1,18 @@
1
+ "{""femprj_path"": null, ""model_name"": ""Ex14""}",prm,prm,obj,obj_direction,obj,obj_direction,obj,obj_direction,,,,,
2
+ ,,,,,,,,,,,,,
3
+ trial,substrate_w,substrate_d,max temp. of<br>MAINCHIP (degree),max temp. of<br>MAINCHIP (degree)_direction,max temp. of<br>SUBCHIP (degree),max temp. of<br>SUBCHIP (degree)_direction,substrate size,substrate size_direction,non_domi,feasible,hypervolume,message,time
4
+ 1,40.0,60.0,37.52037094703595,minimize,37.219570759517936,minimize,2400.0,minimize,True,True,0.0,initial,2024-06-11 12:15:44.138912
5
+ 2,28.741722139252524,58.66928627306774,39.9508830973249,minimize,39.599423416818745,minimize,1686.2563226399373,minimize,True,True,2.970229880317643e-05,,2024-06-11 12:15:48.376064
6
+ 3,35.17589095260529,49.163779073319986,39.86737960935721,minimize,39.626434415381006,minimize,1729.3797347696782,minimize,True,True,0.000549159406835399,,2024-06-11 12:15:52.656210
7
+ 4,24.808335527963855,37.21185204907747,45.61866728905813,minimize,45.454085110378436,minimize,923.164108992346,minimize,True,True,0.0005566073404974778,,2024-06-11 12:15:56.376449
8
+ 5,23.04550501902759,56.38675593592325,42.04691673232563,minimize,41.64255082527148,minimize,1299.4612650272293,minimize,True,True,0.0005567909231334245,,2024-06-11 12:16:00.326849
9
+ 6,32.82007021137776,52.11795960049323,39.9187861643026,minimize,39.65372077487905,minimize,1710.515092752764,minimize,True,True,0.0007091441422963771,,2024-06-11 12:16:04.696885
10
+ 7,22.370520897324443,59.18756600837385,41.85766092262706,minimize,41.41235961737965,minimize,1324.0566822231292,minimize,True,True,0.0007092394191664859,,2024-06-11 12:16:08.614814
11
+ 8,36.98396753440759,38.733155988313456,41.459966487020225,minimize,41.32468375000158,minimize,1432.50578267643,minimize,True,True,0.000726093206891994,,2024-06-11 12:16:12.849722
12
+ 9,25.27284940972781,37.951921766042716,45.203996793500714,minimize,45.02945742624087,minimize,959.1532040919769,minimize,True,True,0.000740299173075068,,2024-06-11 12:16:16.595183
13
+ 10,27.476360373271678,47.16842365407042,42.20017927506254,minimize,41.94996082930303,minimize,1296.0166090811015,minimize,True,True,0.0007432067663207338,,2024-06-11 12:16:20.601673
14
+ 11,30.35761516871566,42.82064718778404,42.23879430266078,minimize,42.04418338920198,minimize,1299.9327303125576,minimize,False,True,0.0007432067663207338,,2024-06-11 12:16:24.664582
15
+ 12,39.45166799418159,54.41754192649335,38.28305390496612,minimize,38.021101163274,minimize,2146.862796414889,minimize,True,True,0.0007445437960082572,,2024-06-11 12:16:29.231158
16
+ 13,33.521593044416015,57.50694947262799,38.98990028232446,minimize,38.68463558069958,minimize,1927.7245558105535,minimize,True,True,0.0008565127001001895,,2024-06-11 12:16:33.869770
17
+ 14,39.51381652632001,59.67156845010898,37.636491167600745,minimize,37.3320157660186,minimize,2357.85140797618,minimize,True,True,0.0009138674403261316,,2024-06-11 12:16:38.728862
18
+ 15,27.034698907527144,51.95067544919728,41.46094657033741,minimize,41.16337804204099,minimize,1404.470867090637,minimize,True,True,0.0009230159948292316,,2024-06-11 12:16:42.930323
@@ -41,7 +41,7 @@ class FemtetInterface(FEMInterface):
41
41
  strictly_pid_specify (bool, optional): If True and connect_method=='new', search launched Femtet process strictly based on its process id.
42
42
  allow_without_project (bool, optional): Allow to launch Femtet with no project file. Default to False.
43
43
  open_result_with_gui (bool, optional): Open analysis result with Femtet GUI. Default to True.
44
- parametric_output_indexes_use_as_objective (list of int, optional): Parametric output indexes which will be used as objective functions. Parametric output should be set on Femtet parametric analysis dialog. Note that output 'No.' in dialog is starts with 1, but this 'index' is starts with 0. Default to None.
44
+ parametric_output_indexes_use_as_objective (dict, optional): Parametric output indexes and their directions which will be used as objective functions. Parametric output should be set on Femtet parametric analysis dialog. Note that output 'No.' in dialog is starts with 1, but this 'index' is starts with 0. The key is the 'index', the value is direction ('maximize', 'minimize' or float). Default to None.
45
45
 
46
46
  Warning:
47
47
  Even if you specify ``strictly_pid_specify=True`` on the constructor,
@@ -199,8 +199,12 @@ class FemtetInterface(FEMInterface):
199
199
  cmd = f'{sys.executable} -m win32com.client.makepy FemtetMacro'
200
200
  os.system(cmd)
201
201
  message = 'Femtet python マクロ定数の設定が完了してないことを検出しました.'
202
- message += '次のコマンドにより、設定は自動で行われました(python -m win32com.client.makepy FemtetMacro).'
203
- message += 'インタープリタを再起動してください.'
202
+ message += '設定は自動で行われました(python -m win32com.client.makepy FemtetMacro).'
203
+ message += 'プログラムを再起動してください.'
204
+ print('================')
205
+ print(message)
206
+ print('================')
207
+ input('終了するには Enter を押してください。')
204
208
  raise RuntimeError(message)
205
209
 
206
210
  if self.Femtet is None:
@@ -270,7 +274,7 @@ class FemtetInterface(FEMInterface):
270
274
  self.Femtet.Gaudi.Activate,
271
275
  False, # None 以外なら何でもいい
272
276
  Exception,
273
- '解析モデルのオープンに失敗しました',
277
+ 'Gaudi のオープンに失敗しました',
274
278
  print_indent=print_indent + 1
275
279
  )
276
280
  except com_error:
@@ -430,14 +434,30 @@ class FemtetInterface(FEMInterface):
430
434
  Otherwise, no check is performed.
431
435
 
432
436
  """
433
- if self._version() >= _version(2023, 1, 1):
434
- variable_names = self.Femtet.GetVariableNames_py()
437
+ major, minor, bugfix = 2023, 1, 1
438
+ if self._version() >= _version(major, minor, bugfix):
439
+ try:
440
+ variable_names = self.Femtet.GetVariableNames_py()
441
+ except AttributeError as e:
442
+ message = 'GetVariableNames_py' + 'にアクセスできません。'
443
+ f'Femtet {major}.{minor}.{bugfix} 以降で「マクロの有効化」が行われていない可能性があります。'
444
+ 'スタートメニューから、インストールされいてる Femtet と同一バージョンの「マクロ機能を有効化する」コマンドを管理者権限で実行してください。'
445
+ print('================')
446
+ logger.error(message)
447
+ print('================')
448
+ input('終了するには Enter を押してください。')
449
+ raise e
450
+
435
451
  if variable_names is not None:
436
452
  if param_name in variable_names:
437
453
  return self.Femtet.GetVariableValue(param_name)
438
454
  message = f'Femtet 解析モデルに変数 {param_name} がありません.'
439
455
  message += f'現在のモデルに設定されている変数は {variable_names} です.'
440
456
  message += '大文字・小文字の区別に注意してください.'
457
+ print('================')
458
+ logger.error(message)
459
+ print('================')
460
+ input('終了するには Enter を押してください。')
441
461
  raise RuntimeError(message)
442
462
  else:
443
463
  return None
@@ -455,8 +475,9 @@ class FemtetInterface(FEMInterface):
455
475
  error_message='解析モデルが開かれていません',
456
476
  )
457
477
 
458
- if self._version() >= _version(2023, 1, 1):
459
- # Femtet の設計変数の更新
478
+ major, minor, bugfix = 2023, 1, 1
479
+ if self._version() >= _version(major, minor, bugfix):
480
+ # Femtet の設計変数の更新(2023.1.1 以降でマクロだけ古い場合はcheck_param_valueで引っかかっているはずなのでここはAttributeError をチェックしない)
460
481
  existing_variable_names = self._call_femtet_api(
461
482
  fun=self.Femtet.GetVariableNames_py,
462
483
  return_value_if_failed=False, # 意味がない
@@ -591,7 +612,22 @@ class FemtetInterface(FEMInterface):
591
612
 
592
613
  def quit(self, timeout=1, force=True):
593
614
  """Force to terminate connected Femtet."""
594
- util.close_femtet(self.Femtet.hWnd, timeout, force)
615
+ major, minor, bugfix = 2024, 0, 1
616
+ if self._version() >= _version(major, minor, bugfix):
617
+ # gracefully termination method without save project available from 2024.0.1
618
+ try:
619
+ self.Femtet.Exit(True)
620
+ except AttributeError as e:
621
+ message = 'Femtet.Exit()' + 'にアクセスできません。'
622
+ f'Femtet {major}.{minor}.{bugfix} 以降で「マクロの有効化」が行われていない可能性があります。'
623
+ 'スタートメニューから、インストールされいてる Femtet と同一バージョンの「マクロ機能を有効化する」コマンドを管理者権限で実行してください。'
624
+ print('================')
625
+ logger.error(message)
626
+ print('================')
627
+ input('終了するには Enter を押してください。')
628
+ raise e
629
+ else:
630
+ util.close_femtet(self.Femtet.hWnd, timeout, force)
595
631
 
596
632
  def _setup_before_parallel(self, client):
597
633
  client.upload_file(
@@ -55,20 +55,20 @@ def _get_prm_result_names(Femtet):
55
55
  return out
56
56
 
57
57
 
58
- def add_parametric_results_as_objectives(femopt, indexes) -> bool:
58
+ def add_parametric_results_as_objectives(femopt, indexes, directions) -> bool:
59
59
  # load dll and set target femtet
60
60
  dll = _get_dll_with_set_femtet(femopt.fem.Femtet)
61
61
 
62
62
  # get objective names
63
63
  dll.GetPrmnResult.restype = ctypes.c_int
64
64
  n = dll.GetPrmnResult()
65
- for i in indexes:
65
+ for i, direction in zip(indexes, directions):
66
66
  # objective name
67
67
  dll.GetPrmResultName.restype = ctypes.c_char_p
68
68
  result = dll.GetPrmResultName(i)
69
69
  name = result.decode('mbcs')
70
70
  # objective value function
71
- femopt.add_objective(_parametric_objective, name, args=(i,))
71
+ femopt.add_objective(_parametric_objective, name, direction=direction, args=(i,))
72
72
  return True # ここまで来たら成功
73
73
 
74
74
 
@@ -81,6 +81,9 @@ def update_single_objective_plot(history, df):
81
81
  df = _ls.localize(df)
82
82
  obj_name = history.obj_names[0]
83
83
 
84
+ df.columns = [c.replace(' / ', '<BR>/ ') for c in df.columns]
85
+ obj_name = obj_name.replace(' / ', '<BR>/ ')
86
+
84
87
  fig = px.scatter(
85
88
  df,
86
89
  x='trial',
@@ -126,6 +129,9 @@ def update_multi_objective_pairplot(history, df):
126
129
 
127
130
  obj_names = history.obj_names
128
131
 
132
+ df.columns = [c.replace(' / ', '<BR>/ ') for c in df.columns]
133
+ obj_names = [o.replace(' / ', '<BR>/ ') for o in obj_names]
134
+
129
135
  common_kwargs = dict(
130
136
  color=_ls.non_domi['label'],
131
137
  color_discrete_map={
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "pyfemtet"
3
- version = "0.4.6" # ignored by versioning plugin
3
+ version = "0.4.7" # ignored by versioning plugin
4
4
  description = "Design parameter optimization using Femtet."
5
5
  authors = ["kazuma.naito <kazuma.naito@murata.com>"]
6
6
  readme = "README.md"
@@ -29,6 +29,7 @@ botorch = [
29
29
  {version = "^0.9.5", python = "<3.12"},
30
30
  {version = ">=0.9.5", python = ">=3.12,<3.13"},
31
31
  ]
32
+ pytest-dashboard = "^0.1.2"
32
33
 
33
34
  [tool.poetry.group.dev.dependencies]
34
35
  pip-licenses = "^4.3.3"
@@ -39,7 +40,6 @@ sphinx-autobuild = "==2021.3.14"
39
40
  pytest = "^7.4.3"
40
41
  sphinx-design = "^0.5.0"
41
42
  bokeh = "^3.3.3"
42
- pytest-dashboard = "*"
43
43
  sphinx-intl = "^2.2.0"
44
44
 
45
45
  [tool.poetry.scripts]
@@ -1 +0,0 @@
1
- __version__ = "0.4.6"
File without changes
File without changes
File without changes
File without changes