pyfemtet 0.4.21__py3-none-any.whl → 0.4.24__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/__init__.py +1 -1
- pyfemtet/_test_util.py +0 -2
- pyfemtet/message/messages.py +15 -1
- pyfemtet/opt/_femopt.py +233 -199
- pyfemtet/opt/_femopt_core.py +116 -47
- pyfemtet/opt/femprj_sample/ParametricIF.py +0 -2
- pyfemtet/opt/femprj_sample/cad_ex01_NX.py +0 -8
- pyfemtet/opt/femprj_sample/cad_ex01_SW.py +0 -8
- pyfemtet/opt/femprj_sample/gal_ex58_parametric.py +0 -8
- pyfemtet/opt/femprj_sample/gau_ex08_parametric.py +0 -8
- pyfemtet/opt/femprj_sample/her_ex40_parametric.py +0 -8
- pyfemtet/opt/femprj_sample/paswat_ex1_parametric.py +0 -8
- pyfemtet/opt/femprj_sample/paswat_ex1_parametric_parallel.py +0 -8
- pyfemtet/opt/femprj_sample/wat_ex14_parametric.py +0 -8
- pyfemtet/opt/femprj_sample/wat_ex14_parametric_parallel.py +0 -8
- pyfemtet/opt/femprj_sample_jp/ParametricIF_jp.py +0 -2
- pyfemtet/opt/femprj_sample_jp/cad_ex01_NX_jp.py +0 -8
- pyfemtet/opt/femprj_sample_jp/cad_ex01_SW_jp.py +0 -8
- pyfemtet/opt/femprj_sample_jp/gal_ex58_parametric_jp.py +0 -8
- pyfemtet/opt/femprj_sample_jp/gau_ex08_parametric_jp.py +0 -8
- pyfemtet/opt/femprj_sample_jp/her_ex40_parametric_jp.py +0 -8
- pyfemtet/opt/femprj_sample_jp/paswat_ex1_parametric_jp.py +0 -8
- pyfemtet/opt/femprj_sample_jp/paswat_ex1_parametric_parallel_jp.py +0 -8
- pyfemtet/opt/femprj_sample_jp/wat_ex14_parametric_jp.py +0 -8
- pyfemtet/opt/femprj_sample_jp/wat_ex14_parametric_parallel_jp.py +0 -8
- pyfemtet/opt/opt/_base.py +4 -4
- pyfemtet/opt/opt/_optuna.py +33 -1
- pyfemtet/opt/opt/_optuna_botorch_helper.py +209 -0
- pyfemtet/opt/visualization/complex_components/main_graph.py +22 -5
- pyfemtet/opt/visualization/complex_components/pm_graph.py +77 -25
- pyfemtet/opt/visualization/complex_components/pm_graph_creator.py +7 -0
- pyfemtet/opt/visualization/process_monitor/application.py +10 -6
- pyfemtet/opt/visualization/process_monitor/pages.py +102 -0
- pyfemtet/opt/visualization/result_viewer/application.py +6 -0
- pyfemtet/opt/visualization/result_viewer/pages.py +1 -1
- {pyfemtet-0.4.21.dist-info → pyfemtet-0.4.24.dist-info}/METADATA +2 -4
- {pyfemtet-0.4.21.dist-info → pyfemtet-0.4.24.dist-info}/RECORD +40 -53
- pyfemtet/FemtetPJTSample/NX_ex01/NX_ex01.femprj +0 -0
- pyfemtet/FemtetPJTSample/NX_ex01/NX_ex01.prt +0 -0
- pyfemtet/FemtetPJTSample/NX_ex01/NX_ex01.py +0 -118
- pyfemtet/FemtetPJTSample/Sldworks_ex01/Sldworks_ex01.SLDPRT +0 -0
- pyfemtet/FemtetPJTSample/Sldworks_ex01/Sldworks_ex01.femprj +0 -0
- pyfemtet/FemtetPJTSample/Sldworks_ex01/Sldworks_ex01.py +0 -121
- pyfemtet/FemtetPJTSample/_her_ex40_parametric.py +0 -148
- pyfemtet/FemtetPJTSample/gau_ex08_parametric.femprj +0 -0
- pyfemtet/FemtetPJTSample/gau_ex08_parametric.py +0 -58
- pyfemtet/FemtetPJTSample/her_ex40_parametric.femprj +0 -0
- pyfemtet/FemtetPJTSample/her_ex40_parametric.py +0 -148
- pyfemtet/FemtetPJTSample/wat_ex14_parallel_parametric.py +0 -65
- pyfemtet/FemtetPJTSample/wat_ex14_parametric.femprj +0 -0
- pyfemtet/FemtetPJTSample/wat_ex14_parametric.py +0 -64
- {pyfemtet-0.4.21.dist-info → pyfemtet-0.4.24.dist-info}/LICENSE +0 -0
- {pyfemtet-0.4.21.dist-info → pyfemtet-0.4.24.dist-info}/WHEEL +0 -0
- {pyfemtet-0.4.21.dist-info → pyfemtet-0.4.24.dist-info}/entry_points.txt +0 -0
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
"""Single-objective optimization: self-inductance of a finite length solenoid coil
|
|
2
|
-
|
|
3
|
-
Perform magnetic field analysis on gau_ex08_parametric.femprj
|
|
4
|
-
to find the dimensions of a finite length solenoid coil
|
|
5
|
-
that makes the self-inductance a specific value.
|
|
6
|
-
"""
|
|
7
|
-
from optuna.integration.botorch import BoTorchSampler
|
|
8
|
-
from pyfemtet.opt import FEMOpt, OptunaOptimizer
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
def inductance(Femtet):
|
|
12
|
-
"""Get the self-inductance.
|
|
13
|
-
|
|
14
|
-
Note:
|
|
15
|
-
The objective or constraint function
|
|
16
|
-
must take a Femtet as its first argument
|
|
17
|
-
and must return a single float.
|
|
18
|
-
|
|
19
|
-
Params:
|
|
20
|
-
Femtet: An instance for using Femtet macros. For more information, see "Femtet Macro Help / CFemtet Class".
|
|
21
|
-
|
|
22
|
-
Returns:
|
|
23
|
-
float: Self-inductance.
|
|
24
|
-
"""
|
|
25
|
-
Gogh = Femtet.Gogh
|
|
26
|
-
|
|
27
|
-
# Get inductance.
|
|
28
|
-
cName = Gogh.Gauss.GetCoilList()[0]
|
|
29
|
-
l = Gogh.Gauss.GetL(cName, cName)
|
|
30
|
-
return l # F
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
if __name__ == '__main__':
|
|
34
|
-
|
|
35
|
-
# Define mathematical optimization object.
|
|
36
|
-
opt = OptunaOptimizer(
|
|
37
|
-
sampler_class=BoTorchSampler,
|
|
38
|
-
sampler_kwargs=dict(
|
|
39
|
-
n_startup_trials=5,
|
|
40
|
-
)
|
|
41
|
-
)
|
|
42
|
-
|
|
43
|
-
# Define FEMOpt object (This process integrates mathematical optimization and FEM.).
|
|
44
|
-
femopt = FEMOpt(opt=opt)
|
|
45
|
-
|
|
46
|
-
# Add design variables (Use variable names set in Femtet) to the optimization problem.
|
|
47
|
-
femopt.add_parameter("h", 3, lower_bound=1.5, upper_bound=6)
|
|
48
|
-
femopt.add_parameter("r", 5, lower_bound=1, upper_bound=10)
|
|
49
|
-
femopt.add_parameter("n", 3, lower_bound=1, upper_bound=5)
|
|
50
|
-
|
|
51
|
-
# Add objective to the optimization problem.
|
|
52
|
-
# The target inductance value is 0.1 uF.
|
|
53
|
-
femopt.add_objective(inductance, name='self-inductance', direction=0.1e-06)
|
|
54
|
-
|
|
55
|
-
# Run optimization.
|
|
56
|
-
femopt.set_random_seed(42)
|
|
57
|
-
femopt.optimize(n_trials=20)
|
|
58
|
-
femopt.terminate_all()
|
|
Binary file
|
|
@@ -1,148 +0,0 @@
|
|
|
1
|
-
"""Single-objective optimization: Resonant frequency of a circular patch antenna
|
|
2
|
-
|
|
3
|
-
Using Femtet’s electromagnetic wave analysis solver,
|
|
4
|
-
we explain an example of setting the resonant frequency
|
|
5
|
-
of a circular patch antenna to a specific value.
|
|
6
|
-
"""
|
|
7
|
-
from time import sleep
|
|
8
|
-
|
|
9
|
-
import numpy as np
|
|
10
|
-
from scipy.signal import find_peaks
|
|
11
|
-
from tqdm import tqdm
|
|
12
|
-
from optuna.integration.botorch import BoTorchSampler
|
|
13
|
-
|
|
14
|
-
from pyfemtet.opt import OptunaOptimizer, FEMOpt
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
class SParameterCalculator:
|
|
18
|
-
"""This class is for calculating S-parameters and resonance frequencies."""
|
|
19
|
-
|
|
20
|
-
def __init__(self):
|
|
21
|
-
self.freq = []
|
|
22
|
-
self.S = []
|
|
23
|
-
self.interpolated_function = None
|
|
24
|
-
self.resonance_frequency = None
|
|
25
|
-
self.minimum_S = None
|
|
26
|
-
|
|
27
|
-
def get_result_from_Femtet(self, Femtet):
|
|
28
|
-
"""Obtain the relationship between frequency and S-parameter from the Femtet analysis results."""
|
|
29
|
-
|
|
30
|
-
# Preparation
|
|
31
|
-
Femtet.OpenCurrentResult(True)
|
|
32
|
-
Gogh = Femtet.Gogh
|
|
33
|
-
|
|
34
|
-
# Obtain the frequency and S(1,1) for each mode
|
|
35
|
-
mode = 0
|
|
36
|
-
freq_list = []
|
|
37
|
-
dB_S_list = []
|
|
38
|
-
for mode in tqdm(range(Gogh.Hertz.nMode), 'Obtaining frequency and S-parameter'):
|
|
39
|
-
# Femtet result screen mode settings
|
|
40
|
-
Gogh.Hertz.Mode = mode
|
|
41
|
-
sleep(0.01)
|
|
42
|
-
# Get frequency
|
|
43
|
-
freq = Gogh.Hertz.GetFreq().Real
|
|
44
|
-
# Get S-parameters
|
|
45
|
-
comp_S = Gogh.Hertz.GetSMatrix(0, 0)
|
|
46
|
-
norm = np.linalg.norm((comp_S.Real, comp_S.Imag))
|
|
47
|
-
dB_S = 20 * np.log10(norm)
|
|
48
|
-
# Get results
|
|
49
|
-
freq_list.append(freq)
|
|
50
|
-
dB_S_list.append(dB_S)
|
|
51
|
-
self.freq = freq_list
|
|
52
|
-
self.S = dB_S_list
|
|
53
|
-
|
|
54
|
-
def calc_resonance_frequency(self):
|
|
55
|
-
"""Compute the frequency that gives the first peak for S-parameter."""
|
|
56
|
-
x = -np.array(self.S)
|
|
57
|
-
peaks, _ = find_peaks(x, height=None, threshold=None, distance=None, prominence=0.5, width=None, wlen=None, rel_height=0.5, plateau_size=None)
|
|
58
|
-
from pyfemtet.core import SolveError
|
|
59
|
-
if len(peaks) == 0:
|
|
60
|
-
raise SolveError('No peaks detected.')
|
|
61
|
-
self.resonance_frequency = self.freq[peaks[0]]
|
|
62
|
-
self.minimum_S = self.S[peaks[0]]
|
|
63
|
-
|
|
64
|
-
def get_resonance_frequency(self, Femtet):
|
|
65
|
-
"""Calculate the resonant frequency.
|
|
66
|
-
|
|
67
|
-
Note:
|
|
68
|
-
The objective or constraint function
|
|
69
|
-
must take a Femtet as its first argument
|
|
70
|
-
and must return a single float.
|
|
71
|
-
|
|
72
|
-
Params:
|
|
73
|
-
Femtet: An instance for using Femtet macros. For more information, see "Femtet Macro Help / CFemtet Class".
|
|
74
|
-
|
|
75
|
-
Returns:
|
|
76
|
-
float: A resonance frequency.
|
|
77
|
-
"""
|
|
78
|
-
self.get_result_from_Femtet(Femtet)
|
|
79
|
-
self.calc_resonance_frequency()
|
|
80
|
-
f = self.resonance_frequency * 1e-9
|
|
81
|
-
return f # GHz
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
def antenna_is_smaller_than_substrate(Femtet):
|
|
85
|
-
"""Calculate the relationship between antenna size and board size.
|
|
86
|
-
|
|
87
|
-
This function is used to constrain the model
|
|
88
|
-
from breaking down while changing parameters.
|
|
89
|
-
|
|
90
|
-
Params:
|
|
91
|
-
Femtet: An instance for using Femtet macros.
|
|
92
|
-
|
|
93
|
-
Returns:
|
|
94
|
-
float: Difference between the board size and antenna size. Must be equal to or grater than 1 mm.
|
|
95
|
-
"""
|
|
96
|
-
ant_r = Femtet.GetVariableValue('ant_r')
|
|
97
|
-
Sx = Femtet.GetVariableValue('sx')
|
|
98
|
-
return Sx/2 - ant_r
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
def port_is_inside_antenna(Femtet):
|
|
102
|
-
"""Calculate the relationship between the feed port location and antenna size.
|
|
103
|
-
|
|
104
|
-
This function is used to constrain the model
|
|
105
|
-
from breaking down while changing parameters.
|
|
106
|
-
|
|
107
|
-
Params:
|
|
108
|
-
Femtet: An instance for using Femtet macros.
|
|
109
|
-
|
|
110
|
-
Returns:
|
|
111
|
-
float: Difference between the antenna edge and the position of the feed port. Must be equal to or grater than 1 mm.
|
|
112
|
-
"""
|
|
113
|
-
ant_r = Femtet.GetVariableValue('ant_r')
|
|
114
|
-
xf = Femtet.GetVariableValue('xf')
|
|
115
|
-
return ant_r - xf
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
if __name__ == '__main__':
|
|
119
|
-
# Define the object for calculating S-parameters and resonance frequencies.
|
|
120
|
-
s = SParameterCalculator()
|
|
121
|
-
|
|
122
|
-
# Define mathematical optimization object.
|
|
123
|
-
opt = OptunaOptimizer(
|
|
124
|
-
sampler_class=BoTorchSampler,
|
|
125
|
-
sampler_kwargs=dict(
|
|
126
|
-
n_startup_trials=10,
|
|
127
|
-
)
|
|
128
|
-
)
|
|
129
|
-
|
|
130
|
-
# Define FEMOpt object (This process integrates mathematical optimization and FEM.).
|
|
131
|
-
femopt = FEMOpt(opt=opt)
|
|
132
|
-
|
|
133
|
-
# Add design variables (Use variable names set in Femtet) to the optimization problem.
|
|
134
|
-
femopt.add_parameter('ant_r', 10, 5, 20)
|
|
135
|
-
femopt.add_parameter('sx', 50, 40, 60)
|
|
136
|
-
femopt.add_parameter('xf', 5, 1, 20)
|
|
137
|
-
|
|
138
|
-
# Add constraint to the optimization problem.
|
|
139
|
-
femopt.add_constraint(antenna_is_smaller_than_substrate, 'board_antenna_clearance', lower_bound=1)
|
|
140
|
-
femopt.add_constraint(port_is_inside_antenna, 'antenna_port_clearance', lower_bound=1)
|
|
141
|
-
|
|
142
|
-
# Add objective to the optimization problem.
|
|
143
|
-
# The target frequency is 3 GHz.
|
|
144
|
-
femopt.add_objective(s.get_resonance_frequency, 'First_resonant_frequency(GHz)', direction=3.0)
|
|
145
|
-
|
|
146
|
-
femopt.set_random_seed(42)
|
|
147
|
-
femopt.optimize(n_trials=20)
|
|
148
|
-
femopt.terminate_all()
|
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
"""Parallel computing / Multi-objective optimization: heating element on board
|
|
2
|
-
|
|
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
|
-
"""
|
|
8
|
-
from pyfemtet.opt import FEMOpt
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
def max_temperature(Femtet, body_name):
|
|
12
|
-
"""Get the maximum temperature of the chip.
|
|
13
|
-
|
|
14
|
-
Note:
|
|
15
|
-
The objective or constraint function
|
|
16
|
-
must take a Femtet as its first argument
|
|
17
|
-
and must return a single float.
|
|
18
|
-
|
|
19
|
-
Params:
|
|
20
|
-
Femtet: An instance for using Femtet macros. For more information, see "Femtet Macro Help / CFemtet Class".
|
|
21
|
-
|
|
22
|
-
Returns:
|
|
23
|
-
float: Max-temperature.
|
|
24
|
-
"""
|
|
25
|
-
Gogh = Femtet.Gogh
|
|
26
|
-
|
|
27
|
-
temp, _, _ = Gogh.Watt.GetTemp_py(body_name)
|
|
28
|
-
|
|
29
|
-
return temp # degree
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
def substrate_size(Femtet):
|
|
33
|
-
"""Calculate the substrate size.
|
|
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.
|
|
40
|
-
"""
|
|
41
|
-
subs_w = Femtet.GetVariableValue('substrate_w')
|
|
42
|
-
subs_d = Femtet.GetVariableValue('substrate_d')
|
|
43
|
-
|
|
44
|
-
return subs_w * subs_d # mm2
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
if __name__ == '__main__':
|
|
48
|
-
|
|
49
|
-
# Define FEMOpt object (This process integrates mathematical optimization and FEM.).
|
|
50
|
-
femopt = FEMOpt()
|
|
51
|
-
|
|
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)
|
|
55
|
-
|
|
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')
|
|
60
|
-
|
|
61
|
-
# Run optimization.
|
|
62
|
-
femopt.set_random_seed(42)
|
|
63
|
-
# femopt.optimize(n_trials=20)
|
|
64
|
-
femopt.optimize(n_trials=20, n_parallel=3) # Change only this line.
|
|
65
|
-
femopt.terminate_all()
|
|
Binary file
|
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
"""Multi-objective optimization: heating element on board
|
|
2
|
-
|
|
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
|
-
"""
|
|
8
|
-
from pyfemtet.opt import FEMOpt
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
def max_temperature(Femtet, body_name):
|
|
12
|
-
"""Get the maximum temperature of the chip.
|
|
13
|
-
|
|
14
|
-
Note:
|
|
15
|
-
The objective or constraint function
|
|
16
|
-
must take a Femtet as its first argument
|
|
17
|
-
and must return a single float.
|
|
18
|
-
|
|
19
|
-
Params:
|
|
20
|
-
Femtet: An instance for using Femtet macros. For more information, see "Femtet Macro Help / CFemtet Class".
|
|
21
|
-
|
|
22
|
-
Returns:
|
|
23
|
-
float: Max-temperature.
|
|
24
|
-
"""
|
|
25
|
-
Gogh = Femtet.Gogh
|
|
26
|
-
|
|
27
|
-
temp, _, _ = Gogh.Watt.GetTemp_py(body_name)
|
|
28
|
-
|
|
29
|
-
return temp # degree
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
def substrate_size(Femtet):
|
|
33
|
-
"""Calculate the substrate size.
|
|
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.
|
|
40
|
-
"""
|
|
41
|
-
subs_w = Femtet.GetVariableValue('substrate_w')
|
|
42
|
-
subs_d = Femtet.GetVariableValue('substrate_d')
|
|
43
|
-
|
|
44
|
-
return subs_w * subs_d # mm2
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
if __name__ == '__main__':
|
|
48
|
-
|
|
49
|
-
# Define FEMOpt object (This process integrates mathematical optimization and FEM.).
|
|
50
|
-
femopt = FEMOpt()
|
|
51
|
-
|
|
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)
|
|
55
|
-
|
|
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')
|
|
60
|
-
|
|
61
|
-
# Run optimization.
|
|
62
|
-
femopt.set_random_seed(42)
|
|
63
|
-
femopt.optimize(n_trials=20)
|
|
64
|
-
femopt.terminate_all()
|
|
File without changes
|
|
File without changes
|
|
File without changes
|