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.
- pyfemtet/FemtetPJTSample/NX_ex01/NX_ex01.py +61 -32
- pyfemtet/FemtetPJTSample/Sldworks_ex01/Sldworks_ex01.py +62 -40
- pyfemtet/FemtetPJTSample/gau_ex08_parametric.py +26 -23
- pyfemtet/FemtetPJTSample/her_ex40_parametric.femprj +0 -0
- pyfemtet/FemtetPJTSample/her_ex40_parametric.py +58 -46
- pyfemtet/FemtetPJTSample/wat_ex14_parallel_parametric.py +31 -29
- pyfemtet/FemtetPJTSample/wat_ex14_parametric.femprj +0 -0
- pyfemtet/FemtetPJTSample/wat_ex14_parametric.py +30 -28
- pyfemtet/__init__.py +1 -1
- pyfemtet/core.py +14 -0
- pyfemtet/dispatch_extensions.py +5 -0
- pyfemtet/opt/__init__.py +22 -2
- pyfemtet/opt/_femopt.py +544 -0
- pyfemtet/opt/_femopt_core.py +732 -0
- pyfemtet/opt/interface/__init__.py +15 -0
- pyfemtet/opt/interface/_base.py +71 -0
- pyfemtet/opt/{interface.py → interface/_femtet.py} +121 -408
- pyfemtet/opt/interface/_femtet_with_nx/__init__.py +3 -0
- pyfemtet/opt/interface/_femtet_with_nx/_interface.py +128 -0
- pyfemtet/opt/interface/_femtet_with_sldworks.py +174 -0
- pyfemtet/opt/opt/__init__.py +8 -0
- pyfemtet/opt/opt/_base.py +202 -0
- pyfemtet/opt/opt/_optuna.py +246 -0
- pyfemtet/opt/visualization/__init__.py +7 -0
- pyfemtet/opt/visualization/_graphs.py +222 -0
- pyfemtet/opt/visualization/_monitor.py +1149 -0
- {pyfemtet-0.3.12.dist-info → pyfemtet-0.4.2.dist-info}/METADATA +6 -5
- pyfemtet-0.4.2.dist-info/RECORD +38 -0
- {pyfemtet-0.3.12.dist-info → pyfemtet-0.4.2.dist-info}/WHEEL +1 -1
- pyfemtet-0.4.2.dist-info/entry_points.txt +3 -0
- pyfemtet/opt/base.py +0 -1490
- pyfemtet/opt/monitor.py +0 -474
- pyfemtet-0.3.12.dist-info/RECORD +0 -26
- /pyfemtet/opt/{_FemtetWithNX → interface/_femtet_with_nx}/update_model.py +0 -0
- {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
|
-
"""
|
|
12
|
+
"""Get the maximum temperature of the chip.
|
|
14
13
|
|
|
15
|
-
|
|
16
|
-
|
|
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
|
-
|
|
19
|
-
|
|
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
|
-
"""
|
|
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
|
|
52
|
-
femopt.add_parameter("substrate_d", 60, lower_bound=33, upper_bound=60
|
|
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='
|
|
56
|
-
femopt.add_objective(max_temperature, name='
|
|
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.
|
|
62
|
-
femopt.
|
|
63
|
+
# femopt.optimize(n_trials=20)
|
|
64
|
+
femopt.optimize(n_trials=20, n_parallel=3) # Change only this line.
|
|
63
65
|
femopt.terminate_all()
|
|
Binary file
|
|
@@ -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
|
-
"""
|
|
12
|
+
"""Get the maximum temperature of the chip.
|
|
14
13
|
|
|
15
|
-
|
|
16
|
-
|
|
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
|
-
|
|
19
|
-
|
|
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
|
-
"""
|
|
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
|
|
52
|
-
femopt.add_parameter("substrate_d", 60, lower_bound=33, upper_bound=60
|
|
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='
|
|
56
|
-
femopt.add_objective(max_temperature, name='
|
|
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.
|
|
63
|
+
femopt.optimize(n_trials=20)
|
|
62
64
|
femopt.terminate_all()
|
pyfemtet/__init__.py
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
__version__ = "0.
|
|
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
|
pyfemtet/dispatch_extensions.py
CHANGED
|
@@ -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 .
|
|
2
|
-
from .interface import
|
|
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
|
+
]
|