pyfemtet 0.3.12__py3-none-any.whl → 0.4.2__py3-none-any.whl

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 (35) hide show
  1. pyfemtet/FemtetPJTSample/NX_ex01/NX_ex01.py +61 -32
  2. pyfemtet/FemtetPJTSample/Sldworks_ex01/Sldworks_ex01.py +62 -40
  3. pyfemtet/FemtetPJTSample/gau_ex08_parametric.py +26 -23
  4. pyfemtet/FemtetPJTSample/her_ex40_parametric.femprj +0 -0
  5. pyfemtet/FemtetPJTSample/her_ex40_parametric.py +58 -46
  6. pyfemtet/FemtetPJTSample/wat_ex14_parallel_parametric.py +31 -29
  7. pyfemtet/FemtetPJTSample/wat_ex14_parametric.femprj +0 -0
  8. pyfemtet/FemtetPJTSample/wat_ex14_parametric.py +30 -28
  9. pyfemtet/__init__.py +1 -1
  10. pyfemtet/core.py +14 -0
  11. pyfemtet/dispatch_extensions.py +5 -0
  12. pyfemtet/opt/__init__.py +22 -2
  13. pyfemtet/opt/_femopt.py +544 -0
  14. pyfemtet/opt/_femopt_core.py +732 -0
  15. pyfemtet/opt/interface/__init__.py +15 -0
  16. pyfemtet/opt/interface/_base.py +71 -0
  17. pyfemtet/opt/{interface.py → interface/_femtet.py} +121 -408
  18. pyfemtet/opt/interface/_femtet_with_nx/__init__.py +3 -0
  19. pyfemtet/opt/interface/_femtet_with_nx/_interface.py +128 -0
  20. pyfemtet/opt/interface/_femtet_with_sldworks.py +174 -0
  21. pyfemtet/opt/opt/__init__.py +8 -0
  22. pyfemtet/opt/opt/_base.py +202 -0
  23. pyfemtet/opt/opt/_optuna.py +246 -0
  24. pyfemtet/opt/visualization/__init__.py +7 -0
  25. pyfemtet/opt/visualization/_graphs.py +222 -0
  26. pyfemtet/opt/visualization/_monitor.py +1149 -0
  27. {pyfemtet-0.3.12.dist-info → pyfemtet-0.4.2.dist-info}/METADATA +6 -5
  28. pyfemtet-0.4.2.dist-info/RECORD +38 -0
  29. {pyfemtet-0.3.12.dist-info → pyfemtet-0.4.2.dist-info}/WHEEL +1 -1
  30. pyfemtet-0.4.2.dist-info/entry_points.txt +3 -0
  31. pyfemtet/opt/base.py +0 -1490
  32. pyfemtet/opt/monitor.py +0 -474
  33. pyfemtet-0.3.12.dist-info/RECORD +0 -26
  34. /pyfemtet/opt/{_FemtetWithNX → interface/_femtet_with_nx}/update_model.py +0 -0
  35. {pyfemtet-0.3.12.dist-info → pyfemtet-0.4.2.dist-info}/LICENSE +0 -0
@@ -1,23 +1,26 @@
1
- """基板上の発熱体
1
+ """Parallel computing / Multi-objective optimization: heating element on board
2
2
 
3
- wat_ex14_parametric.femprj に対し熱伝導解析を行い、
4
- チップの発熱による温度上昇を最小にしつつ
5
- 基板寸法を最小にする
6
- 基板寸法・チップ配置寸法を探索します。
3
+ Perform thermal conduction analysis on wat_ex14_parametric.femprj
4
+ and search for board dimensions and chip placement dimensions that
5
+ minimize the board dimensions while minimizing the temperature rise
6
+ due to chip heat generation.
7
7
  """
8
-
9
8
  from pyfemtet.opt import FEMOpt
10
9
 
11
10
 
12
11
  def max_temperature(Femtet, body_name):
13
- """Femtet の解析結果からチップの最高温度を取得します。
12
+ """Get the maximum temperature of the chip.
14
13
 
15
- Femtet : マクロを使用するためのインスタンスです。詳しくは "Femtet マクロヘルプ / CFemtet クラス" をご覧ください。
16
- 目的関数は第一引数に Femtet インスタンスを取る必要があります。
14
+ Note:
15
+ The objective or constraint function
16
+ must take a Femtet as its first argument
17
+ and must return a single float.
17
18
 
18
- max_temp : 計算された最高温度です。
19
- 目的関数は単一の float を返す必要があります。
19
+ Params:
20
+ Femtet: An instance for using Femtet macros. For more information, see "Femtet Macro Help / CFemtet Class".
20
21
 
22
+ Returns:
23
+ float: Max-temperature.
21
24
  """
22
25
  Gogh = Femtet.Gogh
23
26
 
@@ -27,14 +30,13 @@ def max_temperature(Femtet, body_name):
27
30
 
28
31
 
29
32
  def substrate_size(Femtet):
30
- """Femtet の設計変数から基板サイズを取得します。
31
-
32
- Femtet : マクロを使用するためのインスタンスです。詳しくは "Femtet マクロヘルプ / CFemtet クラス" をご覧ください。
33
- 目的関数は第一引数に Femtet インスタンスを取る必要があります。
34
-
35
- subs_w * subs_d : XY 平面における基板の占有面積です。
36
- 目的関数は単一の float を返す必要があります。
33
+ """Calculate the substrate size.
37
34
 
35
+ Params:
36
+ Femtet: An instance for using Femtet macros. For more information, see "Femtet Macro Help / CFemtet Class".
37
+
38
+ Returns:
39
+ float: The area occupied by the board in the XY plane.
38
40
  """
39
41
  subs_w = Femtet.GetVariableValue('substrate_w')
40
42
  subs_d = Femtet.GetVariableValue('substrate_d')
@@ -44,20 +46,20 @@ def substrate_size(Femtet):
44
46
 
45
47
  if __name__ == '__main__':
46
48
 
47
- # 最適化処理を行うオブジェクトを用意
49
+ # Define FEMOpt object (This process integrates mathematical optimization and FEM.).
48
50
  femopt = FEMOpt()
49
51
 
50
- # 設計変数の設定
51
- femopt.add_parameter("substrate_w", 40, lower_bound=22, upper_bound=40, memo='基板サイズ X')
52
- femopt.add_parameter("substrate_d", 60, lower_bound=33, upper_bound=60, memo='基板サイズ Y')
52
+ # Add design variables (Use variable names set in Femtet) to the optimization problem.
53
+ femopt.add_parameter("substrate_w", 40, lower_bound=22, upper_bound=40)
54
+ femopt.add_parameter("substrate_d", 60, lower_bound=33, upper_bound=60)
53
55
 
54
- # 目的関数の設定
55
- femopt.add_objective(max_temperature, name='メインチップ温度', args=('MAINCHIP',))
56
- femopt.add_objective(max_temperature, name='サブチップ温度', args=('SUBCHIP',))
57
- femopt.add_objective(substrate_size, name='基板サイズ')
56
+ # Add objective to the optimization problem.
57
+ femopt.add_objective(max_temperature, name='main chip temp.', args=('MAINCHIP',))
58
+ femopt.add_objective(max_temperature, name='sub chip temp.', args=('SUBCHIP',))
59
+ femopt.add_objective(substrate_size, name='substrate size')
58
60
 
59
- # 最適化の実行
61
+ # Run optimization.
60
62
  femopt.set_random_seed(42)
61
- # femopt.main(n_trials=20)
62
- femopt.main(n_trials=20, n_parallel=3) # ここのみ wat_ex14_parametric.py から変更しました。
63
+ # femopt.optimize(n_trials=20)
64
+ femopt.optimize(n_trials=20, n_parallel=3) # Change only this line.
63
65
  femopt.terminate_all()
@@ -1,23 +1,26 @@
1
- """基板上の発熱体
1
+ """Multi-objective optimization: heating element on board
2
2
 
3
- wat_ex14_parametric.femprj に対し熱伝導解析を行い、
4
- チップの発熱による温度上昇を最小にしつつ
5
- 基板寸法を最小にする
6
- 基板寸法・チップ配置寸法を探索します。
3
+ Perform thermal conduction analysis on wat_ex14_parametric.femprj
4
+ and search for board dimensions and chip placement dimensions that
5
+ minimize the board dimensions while minimizing the temperature rise
6
+ due to chip heat generation.
7
7
  """
8
-
9
8
  from pyfemtet.opt import FEMOpt
10
9
 
11
10
 
12
11
  def max_temperature(Femtet, body_name):
13
- """Femtet の解析結果からチップの最高温度を取得します。
12
+ """Get the maximum temperature of the chip.
14
13
 
15
- Femtet : マクロを使用するためのインスタンスです。詳しくは "Femtet マクロヘルプ / CFemtet クラス" をご覧ください。
16
- 目的関数は第一引数に Femtet インスタンスを取る必要があります。
14
+ Note:
15
+ The objective or constraint function
16
+ must take a Femtet as its first argument
17
+ and must return a single float.
17
18
 
18
- max_temp : 計算された最高温度です。
19
- 目的関数は単一の float を返す必要があります。
19
+ Params:
20
+ Femtet: An instance for using Femtet macros. For more information, see "Femtet Macro Help / CFemtet Class".
20
21
 
22
+ Returns:
23
+ float: Max-temperature.
21
24
  """
22
25
  Gogh = Femtet.Gogh
23
26
 
@@ -27,14 +30,13 @@ def max_temperature(Femtet, body_name):
27
30
 
28
31
 
29
32
  def substrate_size(Femtet):
30
- """Femtet の設計変数から基板サイズを取得します。
31
-
32
- Femtet : マクロを使用するためのインスタンスです。詳しくは "Femtet マクロヘルプ / CFemtet クラス" をご覧ください。
33
- 目的関数は第一引数に Femtet インスタンスを取る必要があります。
34
-
35
- subs_w * subs_d : XY 平面における基板の占有面積です。
36
- 目的関数は単一の float を返す必要があります。
33
+ """Calculate the substrate size.
37
34
 
35
+ Params:
36
+ Femtet: An instance for using Femtet macros. For more information, see "Femtet Macro Help / CFemtet Class".
37
+
38
+ Returns:
39
+ float: The area occupied by the board in the XY plane.
38
40
  """
39
41
  subs_w = Femtet.GetVariableValue('substrate_w')
40
42
  subs_d = Femtet.GetVariableValue('substrate_d')
@@ -44,19 +46,19 @@ def substrate_size(Femtet):
44
46
 
45
47
  if __name__ == '__main__':
46
48
 
47
- # 最適化処理を行うオブジェクトを用意
49
+ # Define FEMOpt object (This process integrates mathematical optimization and FEM.).
48
50
  femopt = FEMOpt()
49
51
 
50
- # 設計変数の設定
51
- femopt.add_parameter("substrate_w", 40, lower_bound=22, upper_bound=40, memo='基板サイズ X')
52
- femopt.add_parameter("substrate_d", 60, lower_bound=33, upper_bound=60, memo='基板サイズ Y')
52
+ # Add design variables (Use variable names set in Femtet) to the optimization problem.
53
+ femopt.add_parameter("substrate_w", 40, lower_bound=22, upper_bound=40)
54
+ femopt.add_parameter("substrate_d", 60, lower_bound=33, upper_bound=60)
53
55
 
54
- # 目的関数の設定
55
- femopt.add_objective(max_temperature, name='メインチップ温度', args=('MAINCHIP',))
56
- femopt.add_objective(max_temperature, name='サブチップ温度', args=('SUBCHIP',))
57
- femopt.add_objective(substrate_size, name='基板サイズ')
56
+ # Add objective to the optimization problem.
57
+ femopt.add_objective(max_temperature, name='main chip temp.', args=('MAINCHIP',))
58
+ femopt.add_objective(max_temperature, name='sub chip temp.', args=('SUBCHIP',))
59
+ femopt.add_objective(substrate_size, name='substrate size')
58
60
 
59
- # 最適化の実行
61
+ # Run optimization.
60
62
  femopt.set_random_seed(42)
61
- femopt.main(n_trials=20)
63
+ femopt.optimize(n_trials=20)
62
64
  femopt.terminate_all()
pyfemtet/__init__.py CHANGED
@@ -1 +1 @@
1
- __version__ = "0.3.12"
1
+ __version__ = "0.4.2"
pyfemtet/core.py CHANGED
@@ -36,3 +36,17 @@ class SolveError(Exception):
36
36
  class FemtetAutomationError(Exception):
37
37
  """Exception raised for errors in automating Femtet."""
38
38
  pass
39
+
40
+
41
+ def _version(
42
+ main=None,
43
+ major=None,
44
+ minor=None,
45
+ Femtet=None,
46
+ ):
47
+ if Femtet is not None:
48
+ assert (main is None) and (major is None) and (minor is None), 'バージョンを指定しないでください'
49
+ main, major, minor = [int(v) for v in Femtet.Version.split('.')[:3]]
50
+ else:
51
+ assert (main is not None) and (major is not None) and (minor is not None), 'バージョンを指定してください'
52
+ return main*10000 + major*100 + minor
@@ -186,6 +186,7 @@ def dispatch_femtet(timeout=DISPATCH_TIMEOUT, subprocess_log_prefix='') -> Tuple
186
186
 
187
187
  Args:
188
188
  timeout (int or float, optional): Seconds to wait for connection. Defaults to DISPATCH_TIMEOUT.
189
+ subprocess_log_prefix (str, optional): The prefix of log message.
189
190
 
190
191
  Raises:
191
192
  FemtetConnectionTimeoutError: Couldn't connect Femtet process for some reason (i.e. Femtet.exe is not launched).
@@ -461,6 +462,10 @@ def dispatch_specific_femtet_core(pid, timeout=DISPATCH_TIMEOUT) -> Tuple[IFemte
461
462
  return Femtet, my_pid
462
463
 
463
464
 
465
+ def _debug():
466
+ launch_and_dispatch_femtet(5)
467
+
468
+
464
469
  if __name__ == '__main__':
465
470
  _Femtet, _my_pid = launch_and_dispatch_femtet(5)
466
471
  # _Femtet, _my_pid = dispatch_specific_femtet(pid=26124)
pyfemtet/opt/__init__.py CHANGED
@@ -1,2 +1,22 @@
1
- from .base import FEMOpt, OptunaOptimizer
2
- from .interface import FemtetInterface, NoFEM, FemtetWithNXInterface, FemtetWithSolidworksInterface
1
+ from pyfemtet.opt.interface import FEMInterface
2
+ from pyfemtet.opt.interface import NoFEM
3
+ from pyfemtet.opt.interface import FemtetInterface
4
+ from pyfemtet.opt.interface import FemtetWithNXInterface
5
+ from pyfemtet.opt.interface import FemtetWithSolidworksInterface
6
+
7
+ from pyfemtet.opt.opt import OptunaOptimizer
8
+ from pyfemtet.opt.opt import AbstractOptimizer
9
+
10
+ from pyfemtet.opt._femopt import FEMOpt
11
+
12
+
13
+ __all__ = [
14
+ 'FEMOpt',
15
+ 'FEMInterface',
16
+ 'NoFEM',
17
+ 'FemtetInterface',
18
+ 'FemtetWithNXInterface',
19
+ 'FemtetWithSolidworksInterface',
20
+ 'AbstractOptimizer',
21
+ 'OptunaOptimizer',
22
+ ]