pyfemtet 0.9.5__py3-none-any.whl → 1.0.0b0__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 (272) hide show
  1. pyfemtet/__init__.py +6 -1
  2. pyfemtet/_i18n/1. make_pot_and_update_po.bat +8 -0
  3. pyfemtet/_i18n/2. build_mo.bat +5 -0
  4. pyfemtet/_i18n/__init__.py +4 -0
  5. pyfemtet/_i18n/babel.cfg +2 -0
  6. pyfemtet/_i18n/i18n.py +37 -0
  7. pyfemtet/_i18n/locales/ja/LC_MESSAGES/messages.mo +0 -0
  8. pyfemtet/_i18n/locales/ja/LC_MESSAGES/messages.po +1020 -0
  9. pyfemtet/_i18n/locales/messages.pot +987 -0
  10. pyfemtet/{_message → _i18n}/messages.py +128 -41
  11. pyfemtet/_util/closing.py +19 -0
  12. pyfemtet/_util/dask_util.py +89 -7
  13. pyfemtet/_util/df_util.py +29 -0
  14. pyfemtet/_util/excel_macro_util.py +8 -3
  15. pyfemtet/_util/excel_parse_util.py +43 -23
  16. pyfemtet/_util/femtet_access_inspection.py +120 -0
  17. pyfemtet/{_femtet_config_util/autosave.py → _util/femtet_autosave.py} +7 -0
  18. pyfemtet/_util/femtet_exit.py +105 -0
  19. pyfemtet/_util/femtet_version.py +20 -0
  20. pyfemtet/_util/helper.py +94 -0
  21. pyfemtet/_util/process_util.py +107 -0
  22. pyfemtet/_util/str_enum.py +44 -0
  23. pyfemtet/core.py +15 -47
  24. pyfemtet/dispatch_extensions/__init__.py +8 -11
  25. pyfemtet/dispatch_extensions/_impl.py +42 -198
  26. pyfemtet/logger/__init__.py +8 -1
  27. pyfemtet/logger/_impl.py +5 -6
  28. pyfemtet/opt/__init__.py +3 -17
  29. pyfemtet/opt/exceptions.py +45 -0
  30. pyfemtet/opt/femopt.py +608 -0
  31. pyfemtet/opt/history/__init__.py +11 -0
  32. pyfemtet/opt/history/_history.py +1404 -0
  33. pyfemtet/opt/history/_hypervolume.py +169 -0
  34. pyfemtet/opt/history/_optimality.py +79 -0
  35. pyfemtet/opt/interface/__init__.py +17 -24
  36. pyfemtet/opt/interface/_base_interface.py +222 -0
  37. pyfemtet/opt/interface/_excel_interface/__init__.py +3 -0
  38. pyfemtet/opt/interface/_excel_interface/debug-excel-interface.xlsm +0 -0
  39. pyfemtet/opt/interface/_excel_interface/excel_interface.py +999 -0
  40. pyfemtet/opt/interface/_femtet_interface/__init__.py +3 -0
  41. pyfemtet/opt/interface/{_femtet_parametric.py → _femtet_interface/_femtet_parametric.py} +20 -12
  42. pyfemtet/opt/interface/{_femtet.py → _femtet_interface/femtet_interface.py} +505 -349
  43. pyfemtet/opt/interface/_femtet_with_nx_interface/__init__.py +5 -0
  44. pyfemtet/opt/interface/_femtet_with_nx_interface/femtet_with_nx_interface.py +230 -0
  45. pyfemtet/opt/interface/_femtet_with_nx_interface/model1.prt +0 -0
  46. pyfemtet/opt/interface/_femtet_with_nx_interface/model1.x_t +98 -0
  47. pyfemtet/opt/interface/{_femtet_with_nx → _femtet_with_nx_interface}/update_model.py +1 -3
  48. pyfemtet/opt/interface/_femtet_with_solidworks/__init__.py +5 -0
  49. pyfemtet/opt/interface/_femtet_with_solidworks/femtet_with_solidworks_interface.py +122 -0
  50. pyfemtet/opt/interface/_solidworks_interface/__init__.py +5 -0
  51. pyfemtet/opt/interface/_solidworks_interface/solidworks_interface.py +206 -0
  52. pyfemtet/opt/interface/_surrogate_model_interface/__init__.py +8 -0
  53. pyfemtet/opt/interface/_surrogate_model_interface/base_surrogate_interface.py +150 -0
  54. pyfemtet/opt/interface/_surrogate_model_interface/botorch_interface.py +298 -0
  55. pyfemtet/opt/interface/_surrogate_model_interface/debug-pof-botorch.reccsv +18 -0
  56. pyfemtet/opt/interface/_with_excel_settings/__init__.py +61 -0
  57. pyfemtet/opt/interface/_with_excel_settings/with_excel_settings.py +134 -0
  58. pyfemtet/opt/meta_script/YAML_Generator.xlsm +0 -0
  59. pyfemtet/opt/meta_script/__main__.py +58 -36
  60. pyfemtet/opt/optimizer/__init__.py +7 -9
  61. pyfemtet/opt/optimizer/_base_optimizer.py +885 -0
  62. pyfemtet/opt/optimizer/optuna_optimizer/__init__.py +9 -0
  63. pyfemtet/opt/optimizer/optuna_optimizer/_optuna_attribute.py +73 -0
  64. pyfemtet/opt/optimizer/optuna_optimizer/_optuna_optimizer.py +678 -0
  65. pyfemtet/opt/optimizer/optuna_optimizer/_pof_botorch/__init__.py +7 -0
  66. pyfemtet/opt/optimizer/optuna_optimizer/_pof_botorch/debug-pof-botorch.reccsv +18 -0
  67. pyfemtet/opt/optimizer/optuna_optimizer/_pof_botorch/enable_nonlinear_constraint.py +244 -0
  68. pyfemtet/opt/optimizer/optuna_optimizer/_pof_botorch/pof_botorch_sampler.py +1249 -0
  69. pyfemtet/opt/optimizer/optuna_optimizer/wat_ex14_parametric_jp.femprj +0 -0
  70. pyfemtet/opt/optimizer/scipy_optimizer/__init__.py +1 -0
  71. pyfemtet/opt/optimizer/scipy_optimizer/_scipy_optimizer.py +364 -0
  72. pyfemtet/opt/prediction/__init__.py +7 -0
  73. pyfemtet/opt/prediction/_botorch_utils.py +133 -0
  74. pyfemtet/opt/prediction/_gpytorch_modules_extension.py +142 -0
  75. pyfemtet/opt/prediction/_helper.py +155 -0
  76. pyfemtet/opt/prediction/_model.py +118 -0
  77. pyfemtet/opt/problem/problem.py +304 -0
  78. pyfemtet/opt/problem/variable_manager/__init__.py +20 -0
  79. pyfemtet/opt/problem/variable_manager/_string_as_expression.py +115 -0
  80. pyfemtet/opt/problem/variable_manager/_variable_manager.py +295 -0
  81. pyfemtet/opt/visualization/history_viewer/__main__.py +5 -0
  82. pyfemtet/opt/visualization/{_base.py → history_viewer/_base_application.py} +18 -13
  83. pyfemtet/opt/visualization/history_viewer/_common_pages.py +150 -0
  84. pyfemtet/opt/visualization/{_complex_components → history_viewer/_complex_components}/alert_region.py +10 -5
  85. pyfemtet/opt/visualization/{_complex_components → history_viewer/_complex_components}/control_femtet.py +16 -13
  86. pyfemtet/opt/visualization/{_complex_components → history_viewer/_complex_components}/main_graph.py +117 -47
  87. pyfemtet/opt/visualization/{_complex_components → history_viewer/_complex_components}/pm_graph.py +159 -138
  88. pyfemtet/opt/visualization/history_viewer/_process_monitor/_application.py +173 -0
  89. pyfemtet/opt/visualization/history_viewer/_process_monitor/_pages.py +291 -0
  90. pyfemtet/opt/visualization/{_wrapped_components → history_viewer/_wrapped_components}/dbc.py +1 -1
  91. pyfemtet/opt/visualization/{_wrapped_components → history_viewer/_wrapped_components}/dcc.py +1 -1
  92. pyfemtet/opt/visualization/{_wrapped_components → history_viewer/_wrapped_components}/html.py +1 -1
  93. pyfemtet/opt/visualization/history_viewer/result_viewer/__main__.py +5 -0
  94. pyfemtet/opt/visualization/{result_viewer/application.py → history_viewer/result_viewer/_application.py} +6 -6
  95. pyfemtet/opt/visualization/{result_viewer/pages.py → history_viewer/result_viewer/_pages.py} +106 -82
  96. pyfemtet/opt/visualization/history_viewer/result_viewer/tutorial_files/tutorial_gau_ex08.csv +18 -0
  97. pyfemtet/opt/visualization/history_viewer/result_viewer/tutorial_files/tutorial_gau_ex08.db +0 -0
  98. pyfemtet/opt/visualization/history_viewer/result_viewer/tutorial_files/tutorial_gau_ex08_parametric.Results/ex8.jpg +0 -0
  99. pyfemtet/opt/visualization/history_viewer/result_viewer/tutorial_files/tutorial_gau_ex08_parametric.Results/ex8.log +45 -0
  100. pyfemtet/opt/visualization/history_viewer/result_viewer/tutorial_files/tutorial_gau_ex08_parametric.Results/ex8.pdt +0 -0
  101. pyfemtet/opt/visualization/history_viewer/result_viewer/tutorial_files/tutorial_gau_ex08_parametric.Results/ex8_trial_1.jpg +0 -0
  102. pyfemtet/opt/visualization/history_viewer/result_viewer/tutorial_files/tutorial_gau_ex08_parametric.Results/ex8_trial_1.pdt +0 -0
  103. pyfemtet/opt/visualization/history_viewer/result_viewer/tutorial_files/tutorial_gau_ex08_parametric.Results/ex8_trial_10.jpg +0 -0
  104. pyfemtet/opt/visualization/history_viewer/result_viewer/tutorial_files/tutorial_gau_ex08_parametric.Results/ex8_trial_10.pdt +0 -0
  105. pyfemtet/opt/visualization/history_viewer/result_viewer/tutorial_files/tutorial_gau_ex08_parametric.Results/ex8_trial_11.jpg +0 -0
  106. pyfemtet/opt/visualization/history_viewer/result_viewer/tutorial_files/tutorial_gau_ex08_parametric.Results/ex8_trial_11.pdt +0 -0
  107. pyfemtet/opt/visualization/history_viewer/result_viewer/tutorial_files/tutorial_gau_ex08_parametric.Results/ex8_trial_12.jpg +0 -0
  108. pyfemtet/opt/visualization/history_viewer/result_viewer/tutorial_files/tutorial_gau_ex08_parametric.Results/ex8_trial_12.pdt +0 -0
  109. pyfemtet/opt/visualization/history_viewer/result_viewer/tutorial_files/tutorial_gau_ex08_parametric.Results/ex8_trial_13.jpg +0 -0
  110. pyfemtet/opt/visualization/history_viewer/result_viewer/tutorial_files/tutorial_gau_ex08_parametric.Results/ex8_trial_13.pdt +0 -0
  111. pyfemtet/opt/visualization/history_viewer/result_viewer/tutorial_files/tutorial_gau_ex08_parametric.Results/ex8_trial_14.jpg +0 -0
  112. pyfemtet/opt/visualization/history_viewer/result_viewer/tutorial_files/tutorial_gau_ex08_parametric.Results/ex8_trial_14.pdt +0 -0
  113. pyfemtet/opt/visualization/history_viewer/result_viewer/tutorial_files/tutorial_gau_ex08_parametric.Results/ex8_trial_15.jpg +0 -0
  114. pyfemtet/opt/visualization/history_viewer/result_viewer/tutorial_files/tutorial_gau_ex08_parametric.Results/ex8_trial_15.pdt +0 -0
  115. pyfemtet/opt/visualization/history_viewer/result_viewer/tutorial_files/tutorial_gau_ex08_parametric.Results/ex8_trial_16.jpg +0 -0
  116. pyfemtet/opt/visualization/history_viewer/result_viewer/tutorial_files/tutorial_gau_ex08_parametric.Results/ex8_trial_16.pdt +0 -0
  117. pyfemtet/opt/visualization/history_viewer/result_viewer/tutorial_files/tutorial_gau_ex08_parametric.Results/ex8_trial_17.jpg +0 -0
  118. pyfemtet/opt/visualization/history_viewer/result_viewer/tutorial_files/tutorial_gau_ex08_parametric.Results/ex8_trial_17.pdt +0 -0
  119. pyfemtet/opt/visualization/history_viewer/result_viewer/tutorial_files/tutorial_gau_ex08_parametric.Results/ex8_trial_18.jpg +0 -0
  120. pyfemtet/opt/visualization/history_viewer/result_viewer/tutorial_files/tutorial_gau_ex08_parametric.Results/ex8_trial_18.pdt +0 -0
  121. pyfemtet/opt/visualization/history_viewer/result_viewer/tutorial_files/tutorial_gau_ex08_parametric.Results/ex8_trial_19.jpg +0 -0
  122. pyfemtet/opt/visualization/history_viewer/result_viewer/tutorial_files/tutorial_gau_ex08_parametric.Results/ex8_trial_19.pdt +0 -0
  123. pyfemtet/opt/visualization/history_viewer/result_viewer/tutorial_files/tutorial_gau_ex08_parametric.Results/ex8_trial_2.jpg +0 -0
  124. pyfemtet/opt/visualization/history_viewer/result_viewer/tutorial_files/tutorial_gau_ex08_parametric.Results/ex8_trial_2.pdt +0 -0
  125. pyfemtet/opt/visualization/history_viewer/result_viewer/tutorial_files/tutorial_gau_ex08_parametric.Results/ex8_trial_20.jpg +0 -0
  126. pyfemtet/opt/visualization/history_viewer/result_viewer/tutorial_files/tutorial_gau_ex08_parametric.Results/ex8_trial_20.pdt +0 -0
  127. pyfemtet/opt/visualization/history_viewer/result_viewer/tutorial_files/tutorial_gau_ex08_parametric.Results/ex8_trial_3.jpg +0 -0
  128. pyfemtet/opt/visualization/history_viewer/result_viewer/tutorial_files/tutorial_gau_ex08_parametric.Results/ex8_trial_3.pdt +0 -0
  129. pyfemtet/opt/visualization/history_viewer/result_viewer/tutorial_files/tutorial_gau_ex08_parametric.Results/ex8_trial_4.bgr +0 -0
  130. pyfemtet/opt/visualization/history_viewer/result_viewer/tutorial_files/tutorial_gau_ex08_parametric.Results/ex8_trial_4.bnd +0 -0
  131. pyfemtet/opt/visualization/history_viewer/result_viewer/tutorial_files/tutorial_gau_ex08_parametric.Results/ex8_trial_4.btr +0 -0
  132. pyfemtet/opt/visualization/history_viewer/result_viewer/tutorial_files/tutorial_gau_ex08_parametric.Results/ex8_trial_4.jpg +0 -0
  133. pyfemtet/opt/visualization/history_viewer/result_viewer/tutorial_files/tutorial_gau_ex08_parametric.Results/ex8_trial_4.mtl +0 -0
  134. pyfemtet/opt/visualization/history_viewer/result_viewer/tutorial_files/tutorial_gau_ex08_parametric.Results/ex8_trial_4.pdt +0 -0
  135. pyfemtet/opt/visualization/history_viewer/result_viewer/tutorial_files/tutorial_gau_ex08_parametric.Results/ex8_trial_4.prm +0 -0
  136. pyfemtet/opt/visualization/history_viewer/result_viewer/tutorial_files/tutorial_gau_ex08_parametric.Results/ex8_trial_5.jpg +0 -0
  137. pyfemtet/opt/visualization/history_viewer/result_viewer/tutorial_files/tutorial_gau_ex08_parametric.Results/ex8_trial_5.pdt +0 -0
  138. pyfemtet/opt/visualization/history_viewer/result_viewer/tutorial_files/tutorial_gau_ex08_parametric.Results/ex8_trial_6.jpg +0 -0
  139. pyfemtet/opt/visualization/history_viewer/result_viewer/tutorial_files/tutorial_gau_ex08_parametric.Results/ex8_trial_6.pdt +0 -0
  140. pyfemtet/opt/visualization/history_viewer/result_viewer/tutorial_files/tutorial_gau_ex08_parametric.Results/ex8_trial_7.jpg +0 -0
  141. pyfemtet/opt/visualization/history_viewer/result_viewer/tutorial_files/tutorial_gau_ex08_parametric.Results/ex8_trial_7.pdt +0 -0
  142. pyfemtet/opt/visualization/history_viewer/result_viewer/tutorial_files/tutorial_gau_ex08_parametric.Results/ex8_trial_8.jpg +0 -0
  143. pyfemtet/opt/visualization/history_viewer/result_viewer/tutorial_files/tutorial_gau_ex08_parametric.Results/ex8_trial_8.pdt +0 -0
  144. pyfemtet/opt/visualization/history_viewer/result_viewer/tutorial_files/tutorial_gau_ex08_parametric.Results/ex8_trial_9.jpg +0 -0
  145. pyfemtet/opt/visualization/history_viewer/result_viewer/tutorial_files/tutorial_gau_ex08_parametric.Results/ex8_trial_9.pdt +0 -0
  146. pyfemtet/opt/visualization/history_viewer/result_viewer/tutorial_files/tutorial_gau_ex08_parametric.femprj +0 -0
  147. pyfemtet/opt/visualization/plotter/main_figure_creator.py +536 -0
  148. pyfemtet/opt/visualization/plotter/pm_graph_creator.py +359 -0
  149. pyfemtet/opt/worker_status.py +120 -0
  150. {pyfemtet-0.9.5.dist-info → pyfemtet-1.0.0b0.dist-info}/METADATA +23 -24
  151. pyfemtet-1.0.0b0.dist-info/RECORD +172 -0
  152. pyfemtet-1.0.0b0.dist-info/entry_points.txt +3 -0
  153. pyfemtet/_femtet_config_util/exit.py +0 -59
  154. pyfemtet/_message/1. make_pot.bat +0 -11
  155. pyfemtet/_message/2. make_mo.bat +0 -6
  156. pyfemtet/_message/__init__.py +0 -5
  157. pyfemtet/_message/babel.cfg +0 -2
  158. pyfemtet/_message/locales/ja/LC_MESSAGES/messages.mo +0 -0
  159. pyfemtet/_message/locales/ja/LC_MESSAGES/messages.po +0 -570
  160. pyfemtet/_message/locales/messages.pot +0 -551
  161. pyfemtet/_warning.py +0 -87
  162. pyfemtet/brep/_impl.py +0 -18
  163. pyfemtet/opt/_femopt.py +0 -1007
  164. pyfemtet/opt/_femopt_core.py +0 -1169
  165. pyfemtet/opt/_test_utils/control_femtet.py +0 -39
  166. pyfemtet/opt/_test_utils/hyper_sphere.py +0 -24
  167. pyfemtet/opt/_test_utils/record_history.py +0 -130
  168. pyfemtet/opt/advanced_samples/excel_ui/(ref) original_project.femprj +0 -0
  169. pyfemtet/opt/advanced_samples/excel_ui/femtet-macro.xlsm +0 -0
  170. pyfemtet/opt/advanced_samples/excel_ui/pyfemtet-core.py +0 -291
  171. pyfemtet/opt/advanced_samples/excel_ui/test-pyfemtet-core.cmd +0 -22
  172. pyfemtet/opt/advanced_samples/restart/gal_ex13_parametric.femprj +0 -0
  173. pyfemtet/opt/advanced_samples/restart/gal_ex13_parametric_restart.py +0 -99
  174. pyfemtet/opt/advanced_samples/restart/gal_ex13_parametric_restart_jp.py +0 -102
  175. pyfemtet/opt/advanced_samples/surrogate_model/gal_ex13_create_training_data.py +0 -60
  176. pyfemtet/opt/advanced_samples/surrogate_model/gal_ex13_create_training_data_jp.py +0 -57
  177. pyfemtet/opt/advanced_samples/surrogate_model/gal_ex13_optimize_with_surrogate.py +0 -100
  178. pyfemtet/opt/advanced_samples/surrogate_model/gal_ex13_optimize_with_surrogate_jp.py +0 -90
  179. pyfemtet/opt/advanced_samples/surrogate_model/gal_ex13_parametric.femprj +0 -0
  180. pyfemtet/opt/interface/_base.py +0 -101
  181. pyfemtet/opt/interface/_excel_interface.py +0 -984
  182. pyfemtet/opt/interface/_femtet_excel.py +0 -141
  183. pyfemtet/opt/interface/_femtet_with_nx/__init__.py +0 -3
  184. pyfemtet/opt/interface/_femtet_with_nx/_interface.py +0 -178
  185. pyfemtet/opt/interface/_femtet_with_sldworks.py +0 -298
  186. pyfemtet/opt/interface/_surrogate/__init__.py +0 -5
  187. pyfemtet/opt/interface/_surrogate/_base.py +0 -129
  188. pyfemtet/opt/interface/_surrogate/_chaospy.py +0 -71
  189. pyfemtet/opt/interface/_surrogate/_singletaskgp.py +0 -71
  190. pyfemtet/opt/interface/_surrogate_excel.py +0 -102
  191. pyfemtet/opt/optimizer/_base.py +0 -376
  192. pyfemtet/opt/optimizer/_optuna/_botorch_patch/enable_nonlinear_constraint.py +0 -220
  193. pyfemtet/opt/optimizer/_optuna/_optuna.py +0 -434
  194. pyfemtet/opt/optimizer/_optuna/_pof_botorch.py +0 -1914
  195. pyfemtet/opt/optimizer/_scipy.py +0 -159
  196. pyfemtet/opt/optimizer/_scipy_scalar.py +0 -127
  197. pyfemtet/opt/optimizer/parameter.py +0 -113
  198. pyfemtet/opt/prediction/_base.py +0 -61
  199. pyfemtet/opt/prediction/single_task_gp.py +0 -119
  200. pyfemtet/opt/samples/femprj_sample/ParametricIF.femprj +0 -0
  201. pyfemtet/opt/samples/femprj_sample/ParametricIF.py +0 -29
  202. pyfemtet/opt/samples/femprj_sample/ParametricIF_test_result.reccsv +0 -13
  203. pyfemtet/opt/samples/femprj_sample/cad_ex01_NX.femprj +0 -0
  204. pyfemtet/opt/samples/femprj_sample/cad_ex01_NX.prt +0 -0
  205. pyfemtet/opt/samples/femprj_sample/cad_ex01_NX.py +0 -135
  206. pyfemtet/opt/samples/femprj_sample/cad_ex01_NX_test_result.reccsv +0 -23
  207. pyfemtet/opt/samples/femprj_sample/cad_ex01_SW.SLDPRT +0 -0
  208. pyfemtet/opt/samples/femprj_sample/cad_ex01_SW.femprj +0 -0
  209. pyfemtet/opt/samples/femprj_sample/cad_ex01_SW.py +0 -131
  210. pyfemtet/opt/samples/femprj_sample/cad_ex01_SW_test_result.reccsv +0 -23
  211. pyfemtet/opt/samples/femprj_sample/constrained_pipe.femprj +0 -0
  212. pyfemtet/opt/samples/femprj_sample/constrained_pipe.py +0 -96
  213. pyfemtet/opt/samples/femprj_sample/constrained_pipe_test_result.reccsv +0 -13
  214. pyfemtet/opt/samples/femprj_sample/gal_ex58_parametric.femprj +0 -0
  215. pyfemtet/opt/samples/femprj_sample/gal_ex58_parametric.py +0 -74
  216. pyfemtet/opt/samples/femprj_sample/gal_ex58_parametric_test_result.reccsv +0 -13
  217. pyfemtet/opt/samples/femprj_sample/gau_ex08_parametric.femprj +0 -0
  218. pyfemtet/opt/samples/femprj_sample/gau_ex08_parametric.py +0 -58
  219. pyfemtet/opt/samples/femprj_sample/gau_ex08_parametric_test_result.reccsv +0 -23
  220. pyfemtet/opt/samples/femprj_sample/gau_ex12_parametric.femprj +0 -0
  221. pyfemtet/opt/samples/femprj_sample/gau_ex12_parametric.py +0 -52
  222. pyfemtet/opt/samples/femprj_sample/her_ex40_parametric.femprj +0 -0
  223. pyfemtet/opt/samples/femprj_sample/her_ex40_parametric.py +0 -138
  224. pyfemtet/opt/samples/femprj_sample/her_ex40_parametric_test_result.reccsv +0 -18
  225. pyfemtet/opt/samples/femprj_sample/paswat_ex1_parametric.femprj +0 -0
  226. pyfemtet/opt/samples/femprj_sample/paswat_ex1_parametric.py +0 -60
  227. pyfemtet/opt/samples/femprj_sample/paswat_ex1_parametric_parallel.py +0 -61
  228. pyfemtet/opt/samples/femprj_sample/paswat_ex1_parametric_test_result.reccsv +0 -18
  229. pyfemtet/opt/samples/femprj_sample/wat_ex14_parametric.femprj +0 -0
  230. pyfemtet/opt/samples/femprj_sample/wat_ex14_parametric.py +0 -58
  231. pyfemtet/opt/samples/femprj_sample/wat_ex14_parametric_parallel.py +0 -58
  232. pyfemtet/opt/samples/femprj_sample/wat_ex14_parametric_test_result.reccsv +0 -18
  233. pyfemtet/opt/samples/femprj_sample_jp/ParametricIF_jp.femprj +0 -0
  234. pyfemtet/opt/samples/femprj_sample_jp/ParametricIF_jp.py +0 -29
  235. pyfemtet/opt/samples/femprj_sample_jp/cad_ex01_NX_jp.femprj +0 -0
  236. pyfemtet/opt/samples/femprj_sample_jp/cad_ex01_NX_jp.py +0 -129
  237. pyfemtet/opt/samples/femprj_sample_jp/cad_ex01_SW_jp.femprj +0 -0
  238. pyfemtet/opt/samples/femprj_sample_jp/cad_ex01_SW_jp.py +0 -125
  239. pyfemtet/opt/samples/femprj_sample_jp/constrained_pipe_jp.py +0 -93
  240. pyfemtet/opt/samples/femprj_sample_jp/gal_ex58_parametric_jp.femprj +0 -0
  241. pyfemtet/opt/samples/femprj_sample_jp/gal_ex58_parametric_jp.py +0 -70
  242. pyfemtet/opt/samples/femprj_sample_jp/gau_ex08_parametric_jp.femprj +0 -0
  243. pyfemtet/opt/samples/femprj_sample_jp/gau_ex08_parametric_jp.py +0 -57
  244. pyfemtet/opt/samples/femprj_sample_jp/gau_ex12_parametric_jp.py +0 -52
  245. pyfemtet/opt/samples/femprj_sample_jp/her_ex40_parametric_jp.femprj +0 -0
  246. pyfemtet/opt/samples/femprj_sample_jp/her_ex40_parametric_jp.py +0 -138
  247. pyfemtet/opt/samples/femprj_sample_jp/paswat_ex1_parametric_jp.femprj +0 -0
  248. pyfemtet/opt/samples/femprj_sample_jp/paswat_ex1_parametric_jp.py +0 -58
  249. pyfemtet/opt/samples/femprj_sample_jp/paswat_ex1_parametric_parallel_jp.py +0 -59
  250. pyfemtet/opt/samples/femprj_sample_jp/wat_ex14_parametric_jp.py +0 -56
  251. pyfemtet/opt/samples/femprj_sample_jp/wat_ex14_parametric_parallel_jp.py +0 -56
  252. pyfemtet/opt/visualization/_complex_components/main_figure_creator.py +0 -332
  253. pyfemtet/opt/visualization/_complex_components/pm_graph_creator.py +0 -201
  254. pyfemtet/opt/visualization/_process_monitor/application.py +0 -226
  255. pyfemtet/opt/visualization/_process_monitor/pages.py +0 -406
  256. pyfemtet/opt/visualization/_wrapped_components/__init__.py +0 -0
  257. pyfemtet/opt/visualization/result_viewer/__init__.py +0 -0
  258. pyfemtet-0.9.5.dist-info/RECORD +0 -158
  259. pyfemtet-0.9.5.dist-info/entry_points.txt +0 -3
  260. /pyfemtet/{_femtet_config_util → opt/problem}/__init__.py +0 -0
  261. /pyfemtet/{brep → opt/visualization/history_viewer}/__init__.py +0 -0
  262. /pyfemtet/opt/{_test_utils → visualization/history_viewer/_complex_components}/__init__.py +0 -0
  263. /pyfemtet/opt/{optimizer/_optuna → visualization/history_viewer/_process_monitor}/__init__.py +0 -0
  264. /pyfemtet/opt/{optimizer/_optuna/_botorch_patch → visualization/history_viewer/_wrapped_components}/__init__.py +0 -0
  265. /pyfemtet/opt/visualization/{_wrapped_components → history_viewer/_wrapped_components}/str_enum.py +0 -0
  266. /pyfemtet/opt/visualization/{result_viewer → history_viewer/result_viewer}/.gitignore +0 -0
  267. /pyfemtet/opt/visualization/{_complex_components → history_viewer/result_viewer}/__init__.py +0 -0
  268. /pyfemtet/opt/visualization/{_process_monitor → plotter}/__init__.py +0 -0
  269. /pyfemtet/opt/{samples/femprj_sample_jp/wat_ex14_parametric_jp.femprj → wat_ex14_parametric_jp.femprj} +0 -0
  270. {pyfemtet-0.9.5.dist-info → pyfemtet-1.0.0b0.dist-info}/LICENSE +0 -0
  271. {pyfemtet-0.9.5.dist-info → pyfemtet-1.0.0b0.dist-info}/LICENSE_THIRD_PARTY.txt +0 -0
  272. {pyfemtet-0.9.5.dist-info → pyfemtet-1.0.0b0.dist-info}/WHEEL +0 -0
@@ -1,141 +0,0 @@
1
- import re
2
- from pathlib import Path
3
-
4
- from pyfemtet.opt.interface._base import FEMInterface
5
- from pyfemtet.opt.interface._femtet import FemtetInterface
6
- from pyfemtet.opt.interface._excel_interface import (
7
- ExcelInterface, is_cell_value_empty, ParseAsObjective, ScapeGoatObjective,
8
- ParseAsConstraint, search_c, search_r
9
- )
10
-
11
-
12
- PARAMETRIC_PREFIX = 'パラメトリック'
13
-
14
-
15
- def get_number(name):
16
- numbers = re.findall(r'\d+', name)
17
- if len(numbers) == 0:
18
- raise ValueError('パラメトリック結果出力の番号指定が検出できませんでした。')
19
- else:
20
- return int(numbers[0])
21
-
22
-
23
-
24
- class FemtetWithExcelSettingsInterface(FemtetInterface, ExcelInterface, FEMInterface):
25
-
26
- def __init__(
27
- self,
28
-
29
- # FemtetInterface arguments
30
- femprj_path: str = None, model_name: str = None, connect_method: str = 'auto',
31
- save_pdt: str = 'all', strictly_pid_specify: bool = True, allow_without_project: bool = False,
32
- open_result_with_gui: bool = True,
33
- parametric_output_indexes_use_as_objective: dict[int, str or float] = None,
34
-
35
- # ExcelInterface arguments
36
- input_xlsm_path: str or Path = None, input_sheet_name: str = None, output_xlsm_path: str or Path = None,
37
- output_sheet_name: str = None, constraint_xlsm_path: str or Path = None,
38
- constraint_sheet_name: str = None, procedure_name: str = None, procedure_args: list or tuple = None,
39
- procedure_timeout: float or None = None,
40
- setup_xlsm_path: str or Path = None, setup_procedure_name: str = None,
41
- setup_procedure_args: list or tuple = None, teardown_xlsm_path: str or Path = None,
42
- teardown_procedure_name: str = None, teardown_procedure_args: list or tuple = None,
43
- related_file_paths: list[str or Path] = None, visible: bool = False, display_alerts: bool = False,
44
- terminate_excel_when_quit: bool = None, interactive: bool = True, use_named_range: bool = True,
45
-
46
- ):
47
-
48
- excel_connect_method = 'new'
49
-
50
- ExcelInterface.__init__(
51
- self, input_xlsm_path, input_sheet_name, output_xlsm_path, output_sheet_name, constraint_xlsm_path,
52
- constraint_sheet_name, procedure_name, procedure_args, excel_connect_method, procedure_timeout,
53
- setup_xlsm_path, setup_procedure_name, setup_procedure_args, teardown_xlsm_path,
54
- teardown_procedure_name, teardown_procedure_args, related_file_paths, visible, display_alerts,
55
- terminate_excel_when_quit, interactive, use_named_range)
56
-
57
- FemtetInterface.__init__(
58
- self,
59
- femprj_path, model_name, connect_method, save_pdt, strictly_pid_specify, allow_without_project,
60
- open_result_with_gui, parametric_output_indexes_use_as_objective
61
- )
62
-
63
-
64
- def load_objective(self, opt, raise_if_no_keyword=True):
65
- from pyfemtet.opt.optimizer import AbstractOptimizer
66
- from pyfemtet.opt._femopt_core import Objective
67
- opt: AbstractOptimizer
68
-
69
- df = ParseAsObjective.parse(
70
- self.output_xlsm_path,
71
- self.output_sheet_name,
72
- raise_if_no_keyword,
73
- )
74
-
75
- for i, row in df.iterrows():
76
-
77
- # use(optional)
78
- use = True
79
- if ParseAsObjective.use in df.columns:
80
- _use = row[ParseAsObjective.use]
81
- use = False if is_cell_value_empty(_use) else bool(_use) # bool or NaN
82
-
83
- # name
84
- name = str(row[ParseAsObjective.name])
85
-
86
- # direction
87
- direction = row[ParseAsObjective.direction]
88
- assert not is_cell_value_empty(direction), 'direction is empty.'
89
- try:
90
- direction = float(direction)
91
- except ValueError:
92
- direction = str(direction).lower()
93
- assert direction in ['minimize', 'maximize']
94
-
95
- if use:
96
-
97
- # name が「パラメトリック」から始まっていたら
98
- # パラメトリック解析の結果を目的関数にする
99
- if name.startswith(PARAMETRIC_PREFIX):
100
- number = get_number(name)
101
- self.use_parametric_output_as_objective(number, direction)
102
-
103
- # そうでなければ通常の Excel objective を作る
104
- else:
105
- opt.objectives[name] = Objective(
106
- fun=ScapeGoatObjective(),
107
- name=name,
108
- direction=direction,
109
- args=(name,),
110
- kwargs=dict(),
111
- )
112
-
113
- def _setup_before_parallel(self, client):
114
- FemtetInterface._setup_before_parallel(self, client)
115
- ExcelInterface._setup_before_parallel(self, client)
116
-
117
- def _setup_after_parallel(self, *args, **kwargs):
118
- FemtetInterface._setup_after_parallel(self, *args, **kwargs)
119
- ExcelInterface._setup_after_parallel(self, *args, **kwargs)
120
-
121
- def update(self, parameters) -> None:
122
- FemtetInterface.update(self, parameters)
123
- ExcelInterface.update(self, parameters)
124
-
125
- def quit(self, timeout=1, force=True):
126
- FemtetInterface.quit(self, timeout, force)
127
- ExcelInterface.quit(self)
128
-
129
- # noinspection PyMethodOverriding
130
- def objective_from_excel(self, _, name: str):
131
- r = 1 + search_r(self.output_xlsm_path, self.output_sheet_name, name)
132
- c = 1 + search_c(self.output_xlsm_path, self.output_sheet_name, ParseAsObjective.value)
133
- v = self.sh_output.Cells(r, c).value
134
- return float(v)
135
-
136
- # noinspection PyMethodOverriding
137
- def constraint_from_excel(self, _, name: str):
138
- r = 1 + search_r(self.constraint_xlsm_path, self.constraint_sheet_name, name)
139
- c = 1 + search_c(self.constraint_xlsm_path, self.constraint_sheet_name, ParseAsConstraint.value)
140
- v = self.sh_constraint.Cells(r, c).value
141
- return float(v)
@@ -1,3 +0,0 @@
1
- from ._interface import FemtetWithNXInterface
2
-
3
- __all__ = ['FemtetWithNXInterface']
@@ -1,178 +0,0 @@
1
- import os
2
- import json
3
- import subprocess
4
-
5
- import pandas as pd
6
- from dask.distributed import get_worker
7
-
8
- from pyfemtet.core import ModelError
9
- from pyfemtet.opt.interface._femtet import FemtetInterface
10
- from pyfemtet._message import Msg
11
-
12
-
13
- here, me = os.path.split(__file__)
14
-
15
-
16
- class FemtetWithNXInterface(FemtetInterface):
17
- """Control Femtet and NX.
18
-
19
- Using this class, you can import CAD files created
20
- in NX through the Parasolid format into a
21
- Femtet project. It allows you to pass design
22
- variables to NX, update the model, and
23
- perform analysis using the updated model in Femtet.
24
-
25
- Args:
26
- prt_path (str):
27
- The path to .prt file containing the
28
- CAD data from which the import is made.
29
-
30
- export_curves(bool or None, optional):
31
- Defaults to None.
32
- export_surfaces(bool or None, optional):
33
- Defaults to None.
34
- export_solids(bool or None, optional):
35
- Defaults to None.
36
- export_flattened_assembly(bool or None, optional):
37
- Defaults to None.
38
- **kwargs:
39
- For other arguments, please refer to the
40
- :class:`FemtetInterface` class.
41
-
42
- Notes:
43
- ```export_*``` arguments sets
44
- parasolid export setting of NX.
45
- If None, PyFemtet does not change
46
- the current setting of NX.
47
-
48
- It is recommended not to change these values
49
- from the settings used when exporting the
50
- Parasolid that was imported into Femtet.
51
-
52
- """
53
-
54
- _JOURNAL_PATH = os.path.abspath(os.path.join(here, 'update_model.py'))
55
-
56
- def __init__(
57
- self,
58
- prt_path,
59
- export_curves: bool or None = None,
60
- export_surfaces: bool or None = None,
61
- export_solids: bool or None = None,
62
- export_flattened_assembly: bool or None = None,
63
- **kwargs
64
- ):
65
- # check NX installation
66
- self.run_journal_path = os.path.join(os.environ.get('UGII_BASE_DIR'), 'NXBIN', 'run_journal.exe')
67
- if not os.path.isfile(self.run_journal_path):
68
- raise FileNotFoundError(Msg.ERR_RUN_JOURNAL_NOT_FOUND)
69
-
70
- # 引数の処理
71
- # dask サブプロセスのときは prt_path を worker space から取るようにする
72
- try:
73
- worker = get_worker()
74
- space = worker.local_directory
75
- self.prt_path = os.path.join(space, os.path.basename(prt_path))
76
- except ValueError: # get_worker に失敗した場合
77
- self.prt_path = os.path.abspath(prt_path)
78
-
79
- self.export_curves = export_curves
80
- self.export_surfaces = export_surfaces
81
- self.export_solids = export_solids
82
- self.export_flattened_assembly = export_flattened_assembly
83
-
84
- # FemtetInterface の設定 (femprj_path, model_name の更新など)
85
- # + restore 情報の上書き
86
- super().__init__(
87
- prt_path=self.prt_path,
88
- export_curves=self.export_curves,
89
- export_surfaces=self.export_surfaces,
90
- export_solids=self.export_solids,
91
- export_flattened_assembly=self.export_flattened_assembly,
92
- **kwargs
93
- )
94
-
95
- def check_param_value(self, name):
96
- """Override FemtetInterface.check_param_value().
97
-
98
- Do nothing because the parameter can be registered
99
- to not only .femprj but also .prt.
100
-
101
- """
102
- pass
103
-
104
- def _setup_before_parallel(self, client):
105
- client.upload_file(
106
- self.kwargs['prt_path'],
107
- False
108
- )
109
- super()._setup_before_parallel(client)
110
-
111
- def update_model(self, parameters: 'pd.DataFrame', with_warning=False) -> None:
112
- """Update .x_t"""
113
-
114
- self.parameters = parameters.copy()
115
-
116
- # Femtet が参照している x_t パスを取得する
117
- x_t_path = self.Femtet.Gaudi.LastXTPath
118
-
119
- # 前のが存在するならば消しておく
120
- if os.path.isfile(x_t_path):
121
- os.remove(x_t_path)
122
-
123
- # 変数の json 文字列を作る
124
- tmp_dict = {}
125
- for i, row in parameters.iterrows():
126
- tmp_dict[row['name']] = row['value']
127
- str_json = json.dumps(tmp_dict)
128
-
129
- # create dumped json of export settings
130
- tmp_dict = dict(
131
- include_curves=self.export_curves,
132
- include_surfaces=self.export_surfaces,
133
- include_solids=self.export_solids,
134
- flatten_assembly=self.export_flattened_assembly,
135
- )
136
- dumped_json_export_settings = json.dumps(tmp_dict)
137
-
138
- # NX journal を使ってモデルを編集する
139
- env = os.environ.copy()
140
- subprocess.run(
141
- [
142
- self.run_journal_path, # run_journal.exe
143
- self._JOURNAL_PATH, # update_model.py
144
- '-args',
145
- self.prt_path,
146
- str_json,
147
- x_t_path,
148
- dumped_json_export_settings,
149
- ],
150
- env=env,
151
- shell=True,
152
- cwd=os.path.dirname(self.prt_path)
153
- )
154
-
155
- # この時点で x_t ファイルがなければ NX がモデル更新に失敗しているはず
156
- if not os.path.isfile(x_t_path):
157
- raise ModelError
158
-
159
- # モデルの再インポート
160
- self._call_femtet_api(
161
- self.Femtet.Gaudi.ReExecute,
162
- False,
163
- ModelError, # 生きてるのに失敗した場合
164
- error_message=Msg.ERR_MODEL_RECONSTRUCTION_FAILED,
165
- is_Gaudi_method=True,
166
- )
167
-
168
- # 処理を確定
169
- self._call_femtet_api(
170
- self.Femtet.Redraw,
171
- False, # 戻り値は常に None なのでこの変数に意味はなく None 以外なら何でもいい
172
- ModelError, # 生きてるのに失敗した場合
173
- error_message=Msg.ERR_MODEL_UPDATE_FAILED,
174
- is_Gaudi_method=True,
175
- )
176
-
177
- # femprj モデルの変数も更新
178
- super().update_model(parameters, with_warning=False)
@@ -1,298 +0,0 @@
1
- import os
2
- import re
3
- from time import sleep, time
4
-
5
- import pandas as pd
6
- from dask.distributed import get_worker, Lock
7
-
8
- from win32com.client import DispatchEx
9
- # noinspection PyUnresolvedReferences
10
- from pythoncom import CoInitialize, CoUninitialize, com_error
11
-
12
- from pyfemtet.core import ModelError
13
- from pyfemtet.opt.interface._femtet import FemtetInterface
14
- from pyfemtet._message import Msg
15
-
16
-
17
- class FemtetWithSolidworksInterface(FemtetInterface):
18
- """Control Femtet and Solidworks.
19
-
20
- Using this class, you can import CAD files created
21
- in Solidworks through the Parasolid format into a
22
- Femtet project. It allows you to pass design
23
- variables to Solidworks, update the model, and
24
- perform analysis using the updated model in Femtet.
25
-
26
-
27
- Args:
28
- sldprt_path (str):
29
- The path to .sldprt file containing the
30
- CAD data from which the import is made.
31
- **kwargs:
32
- For other arguments, please refer to the
33
- :class:`FemtetInterface` class.
34
-
35
- """
36
-
37
-
38
- # 定数の宣言
39
- swThisConfiguration = 1 # https://help.solidworks.com/2023/english/api/swconst/SOLIDWORKS.Interop.swconst~SOLIDWORKS.Interop.swconst.swInConfigurationOpts_e.html
40
- swAllConfiguration = 2
41
- swSpecifyConfiguration = 3 # use with ConfigName argument
42
- swSaveAsCurrentVersion = 0
43
- swSaveAsOptions_Copy = 2 #
44
- swSaveAsOptions_Silent = 1 # https://help.solidworks.com/2021/english/api/swconst/solidworks.interop.swconst~solidworks.interop.swconst.swsaveasoptions_e.html
45
- swSaveWithReferencesOptions_None = 0 # https://help-solidworks-com.translate.goog/2023/english/api/swconst/SolidWorks.Interop.swconst~SolidWorks.Interop.swconst.swSaveWithReferencesOptions_e.html?_x_tr_sl=auto&_x_tr_tl=ja&_x_tr_hl=ja&_x_tr_pto=wapp
46
- swDocPART = 1 # https://help.solidworks.com/2023/english/api/swconst/SOLIDWORKS.Interop.swconst~SOLIDWORKS.Interop.swconst.swDocumentTypes_e.html
47
-
48
- def __init__(
49
- self,
50
- sldprt_path,
51
- quit_sldworks_on_terminate=False,
52
- **kwargs
53
- ):
54
- # 引数の処理
55
- self._orig_sldprt_basename = os.path.basename(sldprt_path)
56
-
57
- # # dask サブプロセスのときは space 直下の sldprt_path を参照する
58
- # try:
59
- # worker = get_worker()
60
- # space = worker.local_directory
61
- # name_ext = os.path.basename(sldprt_path)
62
- # name, ext = os.path.splitext(name_ext)
63
- # self.sldprt_path = os.path.join(space, name_ext)
64
- #
65
- # # ただし solidworks は 1 プロセスで同名のファイルを開けないので
66
- # # 名前を更新する
67
- # new_sldprt_path = os.path.join(
68
- # space,
69
- # f'{name}'
70
- # f'_{os.path.basename(space)}' # worker に対し一意
71
- # f'{ext}' # ext は . を含む
72
- # )
73
- # os.rename(
74
- # self.sldprt_path,
75
- # new_sldprt_path
76
- # )
77
- # self.sldprt_path = new_sldprt_path
78
- #
79
- # except ValueError: # get_worker に失敗した場合
80
- # self.sldprt_path = os.path.abspath(sldprt_path)
81
- self.sldprt_path = os.path.abspath(sldprt_path)
82
- self.quit_sldworks_on_terminate = quit_sldworks_on_terminate
83
-
84
- # FemtetInterface の設定 (femprj_path, model_name の更新など)
85
- # + restore 情報の上書き
86
- super().__init__(
87
- sldprt_path=self.sldprt_path,
88
- quit_sldworks_on_terminate=self.quit_sldworks_on_terminate,
89
- **kwargs
90
- )
91
-
92
- def initialize_sldworks_connection(self):
93
- # SolidWorks を捕まえ、ファイルを開く
94
-
95
- self.swApp = DispatchEx('SLDWORKS.Application')
96
- self.swApp.Visible = True
97
-
98
- # solidworks は単一プロセスなので開くファイルはひとつだけ
99
- try:
100
- get_worker()
101
- except ValueError:
102
- self.swApp.OpenDoc(self.sldprt_path, self.swDocPART)
103
-
104
- def check_param_value(self, param_name):
105
- """Override FemtetInterface.check_param_value().
106
-
107
- Do nothing because the parameter can be registered
108
- to not only .femprj but also .SLDPRT.
109
-
110
- """
111
- pass
112
-
113
- def _setup_before_parallel(self, client):
114
- client.upload_file(
115
- self.kwargs['sldprt_path'],
116
- False
117
- )
118
- super()._setup_before_parallel(client)
119
-
120
- def _setup_after_parallel(self, *args, **kwargs):
121
- CoInitialize()
122
- self.initialize_sldworks_connection()
123
-
124
- def update_model(self, parameters: pd.DataFrame, with_warning=False):
125
- """Update .x_t"""
126
-
127
- self.parameters = parameters.copy()
128
-
129
- # Femtet が参照している x_t パスを取得する
130
- x_t_path = self.Femtet.Gaudi.LastXTPath
131
-
132
- # dask サブプロセスならば競合しないよう保存先を scratch 直下にしておく
133
- try:
134
- get_worker()
135
- x_t_path = os.path.splitext(self.sldprt_path)[0] + '.x_t'
136
-
137
- except ValueError: # No worker found
138
- pass
139
-
140
- # 前のが存在するならば消しておく
141
- if os.path.isfile(x_t_path):
142
- os.remove(x_t_path)
143
-
144
- # solidworks のモデルの更新
145
- try:
146
- with Lock('update-model-sldworks'):
147
- sleep(0.5) # 並列処理でクラッシュすることが多かったため試験的に導入
148
- self.update_sw_model(parameters, x_t_path)
149
-
150
- # femopt を使わない場合
151
- except RuntimeError: # <class 'distributed.lock.Lock'> object not properly initialized. ...
152
- self.update_sw_model(parameters, x_t_path)
153
-
154
- # dask サブプロセスならば LastXTPath を更新する
155
- try:
156
- get_worker()
157
- try:
158
- self.Femtet.Gaudi.LastXTPath = x_t_path
159
- except (KeyError, AttributeError, com_error):
160
- raise RuntimeError('This feature is available from Femtet version 2023.2. Please update Femtet.')
161
-
162
- # dask を使わない場合
163
- except ValueError: # No worker found
164
- pass
165
-
166
- # モデルの再インポート
167
- self._call_femtet_api(
168
- self.Femtet.Gaudi.ReExecute,
169
- False,
170
- ModelError, # 生きてるのに失敗した場合
171
- error_message=Msg.ERR_RE_EXECUTE_MODEL_FAILED,
172
- is_Gaudi_method=True,
173
- )
174
-
175
- # 処理を確定
176
- self._call_femtet_api(
177
- self.Femtet.Redraw,
178
- False, # 戻り値は常に None なのでこの変数に意味はなく None 以外なら何でもいい
179
- ModelError, # 生きてるのに失敗した場合
180
- error_message=Msg.ERR_MODEL_REDRAW_FAILED,
181
- is_Gaudi_method=True,
182
- )
183
-
184
- # femprj モデルの変数も更新
185
- super().update_model(parameters)
186
-
187
- def update_sw_model(self, parameters: pd.DataFrame, x_t_path):
188
- """Update .sldprt"""
189
-
190
- # df を dict に変換
191
- user_param_dict = {}
192
- for i, row in parameters.iterrows():
193
- user_param_dict[row['name']] = row['value']
194
-
195
- while True:
196
-
197
- try:
198
-
199
- # ===== model を取得 =====
200
- swModel = get_model_by_basename(self.swApp, os.path.basename(self.sldprt_path))
201
-
202
- # ===== equation manager を取得 =====
203
- swEqnMgr = swModel.GetEquationMgr
204
- nEquation = swEqnMgr.GetCount
205
-
206
- # プロパティを退避
207
- buffer_aso = swEqnMgr.AutomaticSolveOrder
208
- buffer_ar = swEqnMgr.AutomaticRebuild
209
- swEqnMgr.AutomaticSolveOrder = False
210
- swEqnMgr.AutomaticRebuild = False
211
-
212
- for i in range(nEquation):
213
- # name, equation の取得
214
- current_equation = swEqnMgr.Equation(i)
215
- current_name = self._get_name_from_equation(current_equation)
216
- # 対象なら処理
217
- if current_name in list(user_param_dict.keys()):
218
- new_equation = f'"{current_name}" = {user_param_dict[current_name]}'
219
- swEqnMgr.Equation(i, new_equation)
220
-
221
- # 式の計算
222
- # noinspection PyStatementEffect
223
- swEqnMgr.EvaluateAll # always returns -1
224
-
225
- # プロパティをもとに戻す
226
- swEqnMgr.AutomaticSolveOrder = buffer_aso
227
- swEqnMgr.AutomaticRebuild = buffer_ar
228
-
229
- # 更新する(ここで失敗はしうる)
230
- result = swModel.EditRebuild3 # モデル再構築
231
- if not result:
232
- raise ModelError(Msg.ERR_UPDATE_SOLIDWORKS_MODEL_FAILED)
233
-
234
- # export as x_t
235
- swModel.SaveAs(x_t_path)
236
-
237
- # 30 秒待っても x_t ができてなければエラー(COM なのでありうる)
238
- timeout = 30
239
- start = time()
240
- while True:
241
- if os.path.isfile(x_t_path):
242
- break
243
- if time() - start > timeout:
244
- raise ModelError(Msg.ERR_MODEL_UPDATE_FAILED)
245
- sleep(1)
246
-
247
- except AttributeError as e:
248
- if 'SLDWORKS.Application.' in str(e):
249
- # re-launch solidworks
250
- self.swApp = DispatchEx('SLDWORKS.Application')
251
- self.swApp.Visible = True
252
- self.swApp.OpenDoc(self.sldprt_path, self.swDocPART)
253
- continue
254
-
255
- else:
256
- raise e
257
-
258
- break
259
-
260
- def _get_name_from_equation(self, equation: str):
261
- pattern = r'^\s*"(.+?)"\s*$'
262
- matched = re.match(pattern, equation.split('=')[0])
263
- if matched:
264
- return matched.group(1)
265
- else:
266
- return None
267
-
268
- def quit(self, timeout=1, force=True):
269
- if self.quit_sldworks_on_terminate:
270
- try:
271
- get_worker()
272
- except ValueError:
273
- try:
274
- self.swApp.ExitApp()
275
- except AttributeError:
276
- pass
277
-
278
- super().quit(timeout, force)
279
-
280
-
281
- def get_model_by_basename(swApp, basename):
282
- swModel = swApp.GetFirstDocument
283
- while swModel is not None:
284
- pathname = swModel.GetPathName
285
- if os.path.basename(pathname) == basename:
286
- from win32com.client import Dispatch
287
- # swModel_ = swApp.ActivateDoc3(
288
- # basename,
289
- # False,
290
- # 1, # swRebuildOnActivation_e.swDontRebuildActiveDoc,
291
- # Dispatch("Scripting.List"),
292
- # )
293
- swApp.OpenDoc(pathname, 1)
294
- swModel_ = swApp.ActiveDoc
295
- return swModel_
296
- else:
297
- swModel = swModel.GetNext
298
- raise ModuleNotFoundError(f'No model named {basename}')
@@ -1,5 +0,0 @@
1
- from pyfemtet.opt.interface._surrogate._singletaskgp import PoFBoTorchInterface
2
-
3
- __all__ = [
4
- PoFBoTorchInterface,
5
- ]