PyFemtet 0.1.4__tar.gz → 0.1.5__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.
Files changed (36) hide show
  1. {pyfemtet-0.1.4 → pyfemtet-0.1.5}/LICENSE +11 -11
  2. {pyfemtet-0.1.4 → pyfemtet-0.1.5}/PKG-INFO +1 -1
  3. {pyfemtet-0.1.4 → pyfemtet-0.1.5}/README.md +140 -140
  4. {pyfemtet-0.1.4/src/PyFemtet → pyfemtet-0.1.5/pyfemtet}/FemtetPJTSample/NX_ex01/NX_ex01 - original.x_t +359 -359
  5. {pyfemtet-0.1.4/src/PyFemtet → pyfemtet-0.1.5/pyfemtet}/FemtetPJTSample/NX_ex01/NX_ex01.py +43 -43
  6. {pyfemtet-0.1.4/src/PyFemtet → pyfemtet-0.1.5/pyfemtet}/FemtetPJTSample/NX_ex01/NX_ex01.x_t +359 -359
  7. {pyfemtet-0.1.4/src/PyFemtet → pyfemtet-0.1.5/pyfemtet}/FemtetPJTSample/gal_ex11_parametric.py +54 -54
  8. {pyfemtet-0.1.4/src/PyFemtet → pyfemtet-0.1.5/pyfemtet}/FemtetPJTSample/gau_ex08_parametric.py +34 -34
  9. {pyfemtet-0.1.4/src/PyFemtet → pyfemtet-0.1.5/pyfemtet}/FemtetPJTSample/her_ex40_parametric.py +102 -102
  10. {pyfemtet-0.1.4/src/PyFemtet → pyfemtet-0.1.5/pyfemtet}/FemtetPJTSample/pas_ex1_parametric.py +66 -66
  11. {pyfemtet-0.1.4/src/PyFemtet → pyfemtet-0.1.5/pyfemtet}/FemtetPJTSample/pas_ex1_parametric2.py +68 -68
  12. pyfemtet-0.1.5/pyfemtet/__init__.py +0 -0
  13. {pyfemtet-0.1.4/src/PyFemtet → pyfemtet-0.1.5/pyfemtet}/opt/_FemtetOptuna.py +282 -282
  14. {pyfemtet-0.1.4/src/PyFemtet → pyfemtet-0.1.5/pyfemtet}/opt/_FemtetScipy.py +146 -146
  15. {pyfemtet-0.1.4/src/PyFemtet → pyfemtet-0.1.5/pyfemtet}/opt/_NX_Femtet.py +68 -68
  16. {pyfemtet-0.1.4/src/PyFemtet → pyfemtet-0.1.5/pyfemtet}/opt/_SW_Femtet.py +163 -163
  17. {pyfemtet-0.1.4/src/PyFemtet → pyfemtet-0.1.5/pyfemtet}/opt/_SimplestUI.py +91 -91
  18. {pyfemtet-0.1.4/src/PyFemtet → pyfemtet-0.1.5/pyfemtet}/opt/__init__.py +2 -2
  19. {pyfemtet-0.1.4/src/PyFemtet → pyfemtet-0.1.5/pyfemtet}/opt/core.py +1348 -1348
  20. {pyfemtet-0.1.4/src/PyFemtet → pyfemtet-0.1.5/pyfemtet}/opt/update_model_parameter.py +83 -83
  21. {pyfemtet-0.1.4/src/PyFemtet → pyfemtet-0.1.5/pyfemtet}/opt/visualization/ProcessMonitor.py +126 -126
  22. {pyfemtet-0.1.4/src/PyFemtet → pyfemtet-0.1.5/pyfemtet}/opt/visualization/__init__.py +2 -2
  23. {pyfemtet-0.1.4/src/PyFemtet → pyfemtet-0.1.5/pyfemtet}/opt/visualization/_dash.py +211 -211
  24. {pyfemtet-0.1.4/src/PyFemtet → pyfemtet-0.1.5/pyfemtet}/opt/visualization/_visualization.py +283 -283
  25. {pyfemtet-0.1.4/src/PyFemtet → pyfemtet-0.1.5/pyfemtet}/opt/visualization/_visualizationNameSpace.py +269 -269
  26. {pyfemtet-0.1.4/src/PyFemtet → pyfemtet-0.1.5/pyfemtet}/tools/DispatchUtils.py +233 -233
  27. {pyfemtet-0.1.4/src/PyFemtet → pyfemtet-0.1.5/pyfemtet}/tools/FemtetClassConst.py +8 -8
  28. {pyfemtet-0.1.4/src/PyFemtet → pyfemtet-0.1.5/pyfemtet}/tools/__init__.py +57 -57
  29. {pyfemtet-0.1.4 → pyfemtet-0.1.5}/pyproject.toml +34 -34
  30. pyfemtet-0.1.4/src/PyFemtet/__init__.py +0 -9
  31. {pyfemtet-0.1.4/src/PyFemtet → pyfemtet-0.1.5/pyfemtet}/FemtetPJTSample/NX_ex01/NX_ex01.femprj +0 -0
  32. {pyfemtet-0.1.4/src/PyFemtet → pyfemtet-0.1.5/pyfemtet}/FemtetPJTSample/NX_ex01/NX_ex01.prt +0 -0
  33. {pyfemtet-0.1.4/src/PyFemtet → pyfemtet-0.1.5/pyfemtet}/FemtetPJTSample/gal_ex11_parametric.femprj +0 -0
  34. {pyfemtet-0.1.4/src/PyFemtet → pyfemtet-0.1.5/pyfemtet}/FemtetPJTSample/gau_ex08_parametric.femprj +0 -0
  35. {pyfemtet-0.1.4/src/PyFemtet → pyfemtet-0.1.5/pyfemtet}/FemtetPJTSample/her_ex40_parametric.femprj +0 -0
  36. {pyfemtet-0.1.4/src/PyFemtet → pyfemtet-0.1.5/pyfemtet}/FemtetPJTSample/pas_ex1_parametric.femprj +0 -0
@@ -1,12 +1,12 @@
1
- Copyright (c) 2023 Murata Manufacturing Co., Ltd.
2
- All rights reserved.
3
-
4
- Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
5
-
6
- 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
7
-
8
- 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
9
-
10
- 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
11
-
1
+ Copyright (c) 2023 Murata Manufacturing Co., Ltd.
2
+ All rights reserved.
3
+
4
+ Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
5
+
6
+ 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
7
+
8
+ 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
9
+
10
+ 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
11
+
12
12
  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS “AS IS” AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: pyfemtet
3
- Version: 0.1.4
3
+ Version: 0.1.5
4
4
  Summary: Design parameter optimization using Femtet.
5
5
  Home-page: https://github.com/kn514/PyFemtet
6
6
  License: BSD-3-Clause
@@ -1,141 +1,141 @@
1
- # Welcome To PyFemtet.opt !
2
- PyFemtet.opt は、Femtet を用いてパラメータ最適化を行うことのできる Python パッケージです。
3
-
4
- ## 機能
5
-
6
- Femtet を使ったシミュレーションによって、パラメータの最適化を行うことができます。
7
- 連続変数の単目的・多目的最適化に対応しています。
8
- いくつかの最適化結果可視化機能を備えており、最適化結果の分析が可能です。
9
-
10
- ***注意:現在、本ライブラリは α 版です!***
11
-
12
- ## install
13
-
14
- インストール方法は以下の通りです。
15
-
16
- 1. Femtet のインストール
17
-
18
- [https://www.muratasoftware.com/](https://www.muratasoftware.com/)
19
-
20
-
21
- 1. Femtet のマクロ有効化
22
-
23
- 詳しくは、Femtet インストール後にスタートメニューから「マクロ機能を有効化する」を選択してください。
24
- マクロ機能を利用するためには excel が必要です。
25
-
26
- 1. Python のインストール
27
-
28
- [https://www.python.org/](https://www.python.org/)
29
-
30
- 1. PyFemtet のインストール
31
-
32
- ```pip install PyFemtet```
33
-
34
- 1. Femtet のアンインストール
35
- PyFemtet をインストールした環境で下記のコマンドを実行してください。依存ライブラリは削除されません。
36
- ```
37
- pip uninstall PyFemtet
38
- ```
39
-
40
- ## 動作するサンプルコード・サンプル解析モデル
41
- .zip ファイル内の以下の位置に、.py ファイルと、それと同名の .femprj ファイルが含まれています。
42
- ```
43
- .\src\PyFemtet\FemtetPJTSample
44
- ```
45
- このフォルダに含まれる ```.femprj``` ファイルは、変数設定済みの単純な解析モデルです。対応する同名の ```.py``` ファイルは、そのパラメータを PyFemtet を用いて最適化するサンプルコードです。
46
-
47
- Femtet でいずれかの ```.femprj``` ファイルを開き、その後対応する ```.py``` ファイルを実行してください。
48
-
49
-
50
-
51
- ## 使い方
52
-
53
- 基本的な使い方は以下の通りです。
54
-
55
- 1. Femtet プロジェクトの作成
56
-
57
- Femtet 上で解析モデルを作成します。最適化したいパラメータを変数として登録してください。
58
-
59
- 1. 評価指標の設定
60
-
61
- 解析結果やモデル形状から評価したい指標を出力する処理を Femtet Python マクロを用いて記述してください。
62
- 以下に例を示します。
63
- ```python
64
- from win32com.client import constants
65
- from win32com.client import Dispatch
66
- Femtet = Dispatch("FemtetMacro.Femtet")
67
-
68
- # マクロから解析結果を開く
69
- Femtet.OpenCurrentResult(True)
70
- # 解析結果を取得するオブジェクトを作成
71
- Gogh = Femtet.Gogh
72
- # 流速を取得する設定
73
- Gogh.Pascal.Vector = constants.PASCAL_VELOCITY_C
74
- # 目的の面で積分し流量を取得
75
- _, ret = Gogh.SimpleIntegralVectorAtFace_py([2], [0], constants.PART_VEC_Y_PART_C)
76
-
77
- print(ret.Real) # 流量(次のステップでこれを評価指標にする)
78
- ```
79
-
80
- 1. メインスクリプトの作成
81
-
82
- 上記で定義した評価指標を含むスクリプトを書いてください。以下に例を示します。前のステップで記述した評価指標が ```get_flow``` 関数の中に記述されています。
83
-
84
- ```python
85
- from PyFemtet.opt import FemtetScipy
86
- from win32com.client import constants
87
- # from win32com.client import Dispatch
88
- # Femtet = Dispatch("FemtetMacro.Femtet") # このスクリプトでは使用しません
89
-
90
- '''h, r という変数を有する解析モデルで簡易流体解析を行い、ある面の流量を 0.3 にしたい場合を想定したスクリプト'''
91
-
92
- # 解析結果から流量を取得する関数
93
- def get_flow(Femtet):
94
- # この関数は、第一引数に Femtet のインスタンスを取るようにしてください。
95
- # Femtet.OpenCurrentResult(True) # この処理はあってもいいですが、不要です
96
- Gogh = Femtet.Gogh
97
- Gogh.Pascal.Vector = constants.PASCAL_VELOCITY_C
98
- _, ret = Gogh.SimpleIntegralVectorAtFace_py([2], [0], constants.PART_VEC_Y_PART_C)
99
- flow = ret.Real
100
- return flow
101
-
102
- # 最適化処理を行うオブジェクトを用意
103
- FEMOpt = FemtetScipy()
104
-
105
- # 解析モデルで登録された変数
106
- FEMOpt.add_parameter("h", 10, memo='高さ')
107
- FEMOpt.add_parameter("r", 5, memo='半径')
108
-
109
- # 流量が 0.3 に近づくようにゴールを設定する
110
- FEMOpt.add_objective(get_flow, name='流量', direction=0.3)
111
-
112
- # 最適化実行中にその収束状況を表示する(experimental)
113
- FEMOpt.set_process_monitor()
114
-
115
- # 最適化の実行 ※実行すると、csv ファイルでの最適化過程の保存が始まります。
116
- FEMOpt.main()
117
-
118
- # 最適化過程の一覧表示(最適化終了時点での csv ファイルの内容と同じです)
119
- print(FEMOpt.history)
120
-
121
- ```
122
- 注意:Femtet 内で数式を設定した変数に対し ```add_parameter``` を行わないでください。数式が失われます。
123
-
124
- 1. ***Femtet で問題の解析モデルを開いた状態で***、スクリプトを実行します。
125
-
126
- - ***最適化を止めるには、計算中の Femtet を終了するか、スクリプトを実行している python プロセスを終了してください。*** それまでの最適化の過程は csv に保存されており、失われません。
127
-
128
- 1. 出力された最適化過程の一覧を確認します。一覧は表形式の構造を持っています。列は *変数、目的、拘束(設定した場合)、非劣解、拘束を満たすかどうか、解析終了時刻* です。各行は、その変数の組み合わせで FEM シミュレーションを行った結果の評価指標の値、拘束の値などを示しています。詳細は、以下も参考にしてください。
129
- - 拘束:ある数式が任意の範囲内にあるようにすることです。具体的な記述方法は**動作するサンプルコード**も参考にしてください。
130
- - 非劣解:劣解とは、解集合の中で、その解よりも全ての評価指標が好ましい解が存在する解のことです。非劣解とは、劣解ではない解のことです。単一の評価指標のみを持つ最適化問題の場合、非劣解は最適解です。
131
-
132
-
133
- ---
134
-
135
- ## English version of this document
136
- We're sorry, this section is under constructing.
137
-
138
- ---
139
- Copyright (C) 2023 kn514 <kazuma.naito@murata.com>
140
- Everyone is permitted to copy and distribute verbatim copies
1
+ # Welcome To PyFemtet.opt !
2
+ PyFemtet.opt は、Femtet を用いてパラメータ最適化を行うことのできる Python パッケージです。
3
+
4
+ ## 機能
5
+
6
+ Femtet を使ったシミュレーションによって、パラメータの最適化を行うことができます。
7
+ 連続変数の単目的・多目的最適化に対応しています。
8
+ いくつかの最適化結果可視化機能を備えており、最適化結果の分析が可能です。
9
+
10
+ ***注意:現在、本ライブラリは α 版です!***
11
+
12
+ ## install
13
+
14
+ インストール方法は以下の通りです。
15
+
16
+ 1. Femtet のインストール
17
+
18
+ [https://www.muratasoftware.com/](https://www.muratasoftware.com/)
19
+
20
+
21
+ 1. Femtet のマクロ有効化
22
+
23
+ 詳しくは、Femtet インストール後にスタートメニューから「マクロ機能を有効化する」を選択してください。
24
+ マクロ機能を利用するためには excel が必要です。
25
+
26
+ 1. Python のインストール
27
+
28
+ [https://www.python.org/](https://www.python.org/)
29
+
30
+ 1. PyFemtet のインストール
31
+
32
+ ```pip install PyFemtet```
33
+
34
+ 1. Femtet のアンインストール
35
+ PyFemtet をインストールした環境で下記のコマンドを実行してください。依存ライブラリは削除されません。
36
+ ```
37
+ pip uninstall PyFemtet
38
+ ```
39
+
40
+ ## 動作するサンプルコード・サンプル解析モデル
41
+ .zip ファイル内の以下の位置に、.py ファイルと、それと同名の .femprj ファイルが含まれています。
42
+ ```
43
+ .\src\PyFemtet\FemtetPJTSample
44
+ ```
45
+ このフォルダに含まれる ```.femprj``` ファイルは、変数設定済みの単純な解析モデルです。対応する同名の ```.py``` ファイルは、そのパラメータを PyFemtet を用いて最適化するサンプルコードです。
46
+
47
+ Femtet でいずれかの ```.femprj``` ファイルを開き、その後対応する ```.py``` ファイルを実行してください。
48
+
49
+
50
+
51
+ ## 使い方
52
+
53
+ 基本的な使い方は以下の通りです。
54
+
55
+ 1. Femtet プロジェクトの作成
56
+
57
+ Femtet 上で解析モデルを作成します。最適化したいパラメータを変数として登録してください。
58
+
59
+ 1. 評価指標の設定
60
+
61
+ 解析結果やモデル形状から評価したい指標を出力する処理を Femtet Python マクロを用いて記述してください。
62
+ 以下に例を示します。
63
+ ```python
64
+ from win32com.client import constants
65
+ from win32com.client import Dispatch
66
+ Femtet = Dispatch("FemtetMacro.Femtet")
67
+
68
+ # マクロから解析結果を開く
69
+ Femtet.OpenCurrentResult(True)
70
+ # 解析結果を取得するオブジェクトを作成
71
+ Gogh = Femtet.Gogh
72
+ # 流速を取得する設定
73
+ Gogh.Pascal.Vector = constants.PASCAL_VELOCITY_C
74
+ # 目的の面で積分し流量を取得
75
+ _, ret = Gogh.SimpleIntegralVectorAtFace_py([2], [0], constants.PART_VEC_Y_PART_C)
76
+
77
+ print(ret.Real) # 流量(次のステップでこれを評価指標にする)
78
+ ```
79
+
80
+ 1. メインスクリプトの作成
81
+
82
+ 上記で定義した評価指標を含むスクリプトを書いてください。以下に例を示します。前のステップで記述した評価指標が ```get_flow``` 関数の中に記述されています。
83
+
84
+ ```python
85
+ from PyFemtet.opt import FemtetScipy
86
+ from win32com.client import constants
87
+ # from win32com.client import Dispatch
88
+ # Femtet = Dispatch("FemtetMacro.Femtet") # このスクリプトでは使用しません
89
+
90
+ '''h, r という変数を有する解析モデルで簡易流体解析を行い、ある面の流量を 0.3 にしたい場合を想定したスクリプト'''
91
+
92
+ # 解析結果から流量を取得する関数
93
+ def get_flow(Femtet):
94
+ # この関数は、第一引数に Femtet のインスタンスを取るようにしてください。
95
+ # Femtet.OpenCurrentResult(True) # この処理はあってもいいですが、不要です
96
+ Gogh = Femtet.Gogh
97
+ Gogh.Pascal.Vector = constants.PASCAL_VELOCITY_C
98
+ _, ret = Gogh.SimpleIntegralVectorAtFace_py([2], [0], constants.PART_VEC_Y_PART_C)
99
+ flow = ret.Real
100
+ return flow
101
+
102
+ # 最適化処理を行うオブジェクトを用意
103
+ FEMOpt = FemtetScipy()
104
+
105
+ # 解析モデルで登録された変数
106
+ FEMOpt.add_parameter("h", 10, memo='高さ')
107
+ FEMOpt.add_parameter("r", 5, memo='半径')
108
+
109
+ # 流量が 0.3 に近づくようにゴールを設定する
110
+ FEMOpt.add_objective(get_flow, name='流量', direction=0.3)
111
+
112
+ # 最適化実行中にその収束状況を表示する(experimental)
113
+ FEMOpt.set_process_monitor()
114
+
115
+ # 最適化の実行 ※実行すると、csv ファイルでの最適化過程の保存が始まります。
116
+ FEMOpt.main()
117
+
118
+ # 最適化過程の一覧表示(最適化終了時点での csv ファイルの内容と同じです)
119
+ print(FEMOpt.history)
120
+
121
+ ```
122
+ 注意:Femtet 内で数式を設定した変数に対し ```add_parameter``` を行わないでください。数式が失われます。
123
+
124
+ 1. ***Femtet で問題の解析モデルを開いた状態で***、スクリプトを実行します。
125
+
126
+ - ***最適化を止めるには、計算中の Femtet を終了するか、スクリプトを実行している python プロセスを終了してください。*** それまでの最適化の過程は csv に保存されており、失われません。
127
+
128
+ 1. 出力された最適化過程の一覧を確認します。一覧は表形式の構造を持っています。列は *変数、目的、拘束(設定した場合)、非劣解、拘束を満たすかどうか、解析終了時刻* です。各行は、その変数の組み合わせで FEM シミュレーションを行った結果の評価指標の値、拘束の値などを示しています。詳細は、以下も参考にしてください。
129
+ - 拘束:ある数式が任意の範囲内にあるようにすることです。具体的な記述方法は**動作するサンプルコード**も参考にしてください。
130
+ - 非劣解:劣解とは、解集合の中で、その解よりも全ての評価指標が好ましい解が存在する解のことです。非劣解とは、劣解ではない解のことです。単一の評価指標のみを持つ最適化問題の場合、非劣解は最適解です。
131
+
132
+
133
+ ---
134
+
135
+ ## English version of this document
136
+ We're sorry, this section is under constructing.
137
+
138
+ ---
139
+ Copyright (C) 2023 kn514 <kazuma.naito@murata.com>
140
+ Everyone is permitted to copy and distribute verbatim copies
141
141
  of this license document, but changing it is not allowed.