fiqus 2024.7.0__tar.gz → 2024.12.0__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 (108) hide show
  1. fiqus-2024.12.0/PKG-INFO +70 -0
  2. fiqus-2024.12.0/README.md +54 -0
  3. fiqus-2024.12.0/fiqus/MainFiQuS.py +509 -0
  4. {fiqus-2024.7.0 → fiqus-2024.12.0}/fiqus/data/DataConductor.py +301 -301
  5. fiqus-2024.12.0/fiqus/data/DataFiQuS.py +227 -0
  6. {fiqus-2024.7.0 → fiqus-2024.12.0}/fiqus/data/DataFiQuSCCT.py +150 -150
  7. {fiqus-2024.7.0 → fiqus-2024.12.0}/fiqus/data/DataFiQuSConductor.py +84 -84
  8. {fiqus-2024.7.0 → fiqus-2024.12.0}/fiqus/data/DataFiQuSConductorAC_Strand.py +565 -565
  9. fiqus-2024.12.0/fiqus/data/DataFiQuSMultipole.py +740 -0
  10. {fiqus-2024.7.0 → fiqus-2024.12.0}/fiqus/data/DataFiQuSPancake3D.py +737 -278
  11. fiqus-2024.12.0/fiqus/data/DataMultipole.py +264 -0
  12. {fiqus-2024.7.0 → fiqus-2024.12.0}/fiqus/data/DataRoxieParser.py +90 -51
  13. fiqus-2024.12.0/fiqus/data/DataSettings.py +121 -0
  14. {fiqus-2024.7.0 → fiqus-2024.12.0}/fiqus/data/DataWindingsCCT.py +37 -37
  15. {fiqus-2024.7.0 → fiqus-2024.12.0}/fiqus/data/RegionsModelFiQuS.py +18 -6
  16. {fiqus-2024.7.0 → fiqus-2024.12.0}/fiqus/geom_generators/GeometryCCT.py +905 -905
  17. {fiqus-2024.7.0 → fiqus-2024.12.0}/fiqus/geom_generators/GeometryConductorAC_Strand.py +1391 -1391
  18. fiqus-2024.12.0/fiqus/geom_generators/GeometryMultipole.py +1987 -0
  19. {fiqus-2024.7.0 → fiqus-2024.12.0}/fiqus/geom_generators/GeometryPancake3D.py +316 -117
  20. fiqus-2024.12.0/fiqus/geom_generators/GeometryPancake3DUtils.py +549 -0
  21. {fiqus-2024.7.0 → fiqus-2024.12.0}/fiqus/getdp_runners/RunGetdpCCT.py +4 -4
  22. {fiqus-2024.7.0 → fiqus-2024.12.0}/fiqus/getdp_runners/RunGetdpConductorAC_Strand.py +201 -201
  23. fiqus-2024.12.0/fiqus/getdp_runners/RunGetdpMultipole.py +170 -0
  24. {fiqus-2024.7.0 → fiqus-2024.12.0}/fiqus/getdp_runners/RunGetdpPancake3D.py +28 -6
  25. {fiqus-2024.7.0 → fiqus-2024.12.0}/fiqus/mains/MainCCT.py +2 -2
  26. {fiqus-2024.7.0 → fiqus-2024.12.0}/fiqus/mains/MainConductorAC_Strand.py +132 -132
  27. fiqus-2024.12.0/fiqus/mains/MainMultipole.py +182 -0
  28. {fiqus-2024.7.0 → fiqus-2024.12.0}/fiqus/mains/MainPancake3D.py +63 -23
  29. {fiqus-2024.7.0 → fiqus-2024.12.0}/fiqus/mesh_generators/MeshCCT.py +209 -209
  30. {fiqus-2024.7.0 → fiqus-2024.12.0}/fiqus/mesh_generators/MeshConductorAC_Strand.py +656 -656
  31. fiqus-2024.12.0/fiqus/mesh_generators/MeshMultipole.py +1347 -0
  32. {fiqus-2024.7.0 → fiqus-2024.12.0}/fiqus/mesh_generators/MeshPancake3D.py +275 -192
  33. fiqus-2024.12.0/fiqus/parsers/ParserCOND.py +825 -0
  34. {fiqus-2024.7.0 → fiqus-2024.12.0}/fiqus/parsers/ParserDAT.py +16 -16
  35. {fiqus-2024.7.0 → fiqus-2024.12.0}/fiqus/parsers/ParserGetDPOnSection.py +212 -212
  36. {fiqus-2024.7.0 → fiqus-2024.12.0}/fiqus/parsers/ParserGetDPTimeTable.py +134 -134
  37. {fiqus-2024.7.0 → fiqus-2024.12.0}/fiqus/parsers/ParserMSH.py +53 -53
  38. {fiqus-2024.7.0 → fiqus-2024.12.0}/fiqus/parsers/ParserPOS.py +214 -214
  39. {fiqus-2024.7.0 → fiqus-2024.12.0}/fiqus/parsers/ParserRES.py +142 -142
  40. {fiqus-2024.7.0 → fiqus-2024.12.0}/fiqus/plotters/PlotPythonCCT.py +133 -133
  41. {fiqus-2024.7.0 → fiqus-2024.12.0}/fiqus/plotters/PlotPythonConductorAC.py +855 -855
  42. {fiqus-2024.7.0 → fiqus-2024.12.0}/fiqus/plotters/PlotPythonMultipole.py +18 -18
  43. {fiqus-2024.7.0 → fiqus-2024.12.0}/fiqus/post_processors/PostProcessCCT.py +440 -440
  44. {fiqus-2024.7.0 → fiqus-2024.12.0}/fiqus/post_processors/PostProcessConductorAC.py +49 -49
  45. fiqus-2024.12.0/fiqus/post_processors/PostProcessMultipole.py +410 -0
  46. {fiqus-2024.7.0 → fiqus-2024.12.0}/fiqus/post_processors/PostProcessPancake3D.py +8 -13
  47. {fiqus-2024.7.0 → fiqus-2024.12.0}/fiqus/pre_processors/PreProcessCCT.py +175 -175
  48. {fiqus-2024.7.0 → fiqus-2024.12.0}/fiqus/pro_assemblers/ProAssembler.py +14 -6
  49. {fiqus-2024.7.0 → fiqus-2024.12.0}/fiqus/pro_material_functions/ironBHcurves.pro +246 -246
  50. {fiqus-2024.7.0 → fiqus-2024.12.0}/fiqus/pro_templates/combined/CCT_template.pro +274 -274
  51. {fiqus-2024.7.0 → fiqus-2024.12.0}/fiqus/pro_templates/combined/ConductorAC_template.pro +1025 -1025
  52. fiqus-2024.12.0/fiqus/pro_templates/combined/Multipole_template.pro +1805 -0
  53. fiqus-2024.12.0/fiqus/pro_templates/combined/Pancake3D_template.pro +4758 -0
  54. fiqus-2024.12.0/fiqus/pro_templates/combined/TSA_materials.pro +162 -0
  55. {fiqus-2024.7.0 → fiqus-2024.12.0}/fiqus/pro_templates/combined/materials.pro +36 -18
  56. fiqus-2024.12.0/fiqus/utils/Utils.py +815 -0
  57. fiqus-2024.12.0/fiqus/utils/update_data_settings.py +33 -0
  58. fiqus-2024.12.0/fiqus.egg-info/PKG-INFO +70 -0
  59. {fiqus-2024.7.0 → fiqus-2024.12.0}/fiqus.egg-info/SOURCES.txt +5 -0
  60. fiqus-2024.12.0/fiqus.egg-info/requires.txt +68 -0
  61. {fiqus-2024.7.0 → fiqus-2024.12.0}/setup.py +18 -16
  62. {fiqus-2024.7.0 → fiqus-2024.12.0}/tests/test_FiQuS.py +1 -1
  63. fiqus-2024.12.0/tests/test_geometry_generators.py +190 -0
  64. fiqus-2024.12.0/tests/test_mesh_generators.py +252 -0
  65. fiqus-2024.12.0/tests/test_solvers.py +242 -0
  66. {fiqus-2024.7.0 → fiqus-2024.12.0}/tests/utils/fiqus_test_classes.py +85 -21
  67. {fiqus-2024.7.0 → fiqus-2024.12.0}/tests/utils/generate_reference_files_ConductorAC.py +57 -57
  68. {fiqus-2024.7.0 → fiqus-2024.12.0}/tests/utils/generate_reference_files_Pancake3D.py +4 -5
  69. {fiqus-2024.7.0 → fiqus-2024.12.0}/tests/utils/helpers.py +97 -97
  70. fiqus-2024.7.0/PKG-INFO +0 -103
  71. fiqus-2024.7.0/README.md +0 -37
  72. fiqus-2024.7.0/fiqus/MainFiQuS.py +0 -353
  73. fiqus-2024.7.0/fiqus/data/DataFiQuS.py +0 -183
  74. fiqus-2024.7.0/fiqus/data/DataFiQuSMultipole.py +0 -66
  75. fiqus-2024.7.0/fiqus/data/DataMultipole.py +0 -99
  76. fiqus-2024.7.0/fiqus/geom_generators/GeometryMultipole.py +0 -387
  77. fiqus-2024.7.0/fiqus/getdp_runners/RunGetdpMultipole.py +0 -97
  78. fiqus-2024.7.0/fiqus/mains/MainMultipole.py +0 -131
  79. fiqus-2024.7.0/fiqus/mesh_generators/MeshMultipole.py +0 -285
  80. fiqus-2024.7.0/fiqus/post_processors/PostProcessMultipole.py +0 -286
  81. fiqus-2024.7.0/fiqus/pro_templates/combined/Multipole_template.pro +0 -237
  82. fiqus-2024.7.0/fiqus/pro_templates/combined/Pancake3D_template.pro +0 -3567
  83. fiqus-2024.7.0/fiqus/utils/Utils.py +0 -417
  84. fiqus-2024.7.0/fiqus.egg-info/PKG-INFO +0 -103
  85. fiqus-2024.7.0/fiqus.egg-info/requires.txt +0 -58
  86. fiqus-2024.7.0/tests/test_geometry_generators.py +0 -91
  87. fiqus-2024.7.0/tests/test_mesh_generators.py +0 -99
  88. fiqus-2024.7.0/tests/test_solvers.py +0 -148
  89. {fiqus-2024.7.0 → fiqus-2024.12.0}/fiqus/__init__.py +0 -0
  90. {fiqus-2024.7.0 → fiqus-2024.12.0}/fiqus/data/__init__.py +0 -0
  91. {fiqus-2024.7.0 → fiqus-2024.12.0}/fiqus/geom_generators/__init__.py +0 -0
  92. {fiqus-2024.7.0 → fiqus-2024.12.0}/fiqus/getdp_runners/__init__.py +0 -0
  93. {fiqus-2024.7.0 → fiqus-2024.12.0}/fiqus/mains/__init__.py +0 -0
  94. {fiqus-2024.7.0 → fiqus-2024.12.0}/fiqus/mesh_generators/__init__.py +0 -0
  95. {fiqus-2024.7.0 → fiqus-2024.12.0}/fiqus/parsers/__init__.py +0 -0
  96. {fiqus-2024.7.0 → fiqus-2024.12.0}/fiqus/plotters/__init__.py +0 -0
  97. {fiqus-2024.7.0 → fiqus-2024.12.0}/fiqus/post_processors/__init__.py +0 -0
  98. {fiqus-2024.7.0 → fiqus-2024.12.0}/fiqus/pre_processors/__init__.py +0 -0
  99. {fiqus-2024.7.0 → fiqus-2024.12.0}/fiqus/pro_assemblers/__init__.py +0 -0
  100. {fiqus-2024.7.0 → fiqus-2024.12.0}/fiqus/pro_templates/__init__.py +0 -0
  101. {fiqus-2024.7.0 → fiqus-2024.12.0}/fiqus/pro_templates/combined/__init__.py +0 -0
  102. {fiqus-2024.7.0 → fiqus-2024.12.0}/fiqus/pro_templates/separated/__init__.py +0 -0
  103. {fiqus-2024.7.0 → fiqus-2024.12.0}/fiqus/utils/__init__.py +0 -0
  104. {fiqus-2024.7.0 → fiqus-2024.12.0}/fiqus.egg-info/dependency_links.txt +0 -0
  105. {fiqus-2024.7.0 → fiqus-2024.12.0}/fiqus.egg-info/top_level.txt +0 -0
  106. {fiqus-2024.7.0 → fiqus-2024.12.0}/setup.cfg +0 -0
  107. {fiqus-2024.7.0 → fiqus-2024.12.0}/tests/__init__.py +0 -0
  108. {fiqus-2024.7.0 → fiqus-2024.12.0}/tests/utils/__init__.py +0 -0
@@ -0,0 +1,70 @@
1
+ Metadata-Version: 2.1
2
+ Name: fiqus
3
+ Version: 2024.12.0
4
+ Summary: Source code for STEAM FiQuS tool
5
+ Home-page: https://gitlab.cern.ch/steam/fiqus
6
+ Author: STEAM Team
7
+ Author-email: steam-team@cern.ch
8
+ Keywords: STEAM,FiQuS,CERN
9
+ Classifier: Programming Language :: Python :: 3.11
10
+ Requires-Python: >=3.11
11
+ Description-Content-Type: text/markdown
12
+ Provides-Extra: all
13
+ Provides-Extra: docs
14
+ Provides-Extra: tests
15
+ Provides-Extra: build
16
+
17
+ ![FiQuS logo](https://gitlab.cern.ch/steam/fiqus/-/raw/master/docs/images/FiQuS_name_logo.svg)
18
+
19
+ # Introduction
20
+ Source code for STEAM **FiQuS** (**Fi**nite Element **Qu**ench **S**imulator).
21
+
22
+ # Publications
23
+
24
+ ## Describing FiQuS Modules
25
+ - S. Atalay et al, "An open-source 3D FE quench simulation tool for no-insulation HTS pancake coils", in Superconductor Science and Technology, doi: [10.1088/1361-6668/ad3f83](https://doi.org/10.1088/1361-6668/ad3f83)
26
+ - J. Dular et al, "Coupled Axial and Transverse Currents Method for Finite Element Modelling of Periodic Superconductors", arXiv preprint, doi:[10.48550/arXiv.2404.09775](https://doi.org/10.48550/arXiv.2404.09775).
27
+ - A. Vitrano et al, "An Open-Source Finite Element Quench Simulation Tool for Superconducting Magnets," in IEEE Transactions on Applied Superconductivity, vol. 33, no. 5, pp. 1-6, Aug. 2023, Art no. 4702006, doi: [10.1109/TASC.2023.3259332](https://ieeexplore.ieee.org/abstract/document/10077402).
28
+
29
+ ## Using FiQuS
30
+
31
+ - J. Dular et al, "Simulation of Rutherford Cable AC Loss and Magnetization with the Coupled Axial and Transverse Currents Method", accepted for publication in IEEE Transactions on Applied Superconductivity, [arXiv:2411.13347](https://arxiv.org/abs/2411.13347).
32
+ - M. Wozniak et al, "Influence of Critical Current Distribution on Operation, Quench Detection and Protection of HTS Pancake Coils, submitted for publication in IEEE Transactions on Applied Superconductivity, [arXiv:2411.18124](https://arxiv.org/abs/2411.18124).
33
+ - Laura AM D’Angelo et al, "Efficient Reduced Magnetic Vector Potential Formulation for the Magnetic Field Simulation of Accelerator Magnets", in IEEE Transactions on Magnetics, vol. 60, no. 3, pp. 1-8, Jan. 2024, Art no. 7000808, doi: [10.1109/TMAG.2024.3352113](https://ieeexplore.ieee.org/abstract/document/10387412).
34
+ - M. Wozniak et al, "Quench Co-Simulation of Canted Cos-Theta Magnets," in IEEE Transactions on Applied Superconductivity, vol. 34, no. 3, pp. 1-5, Dec. 2023, Art no. 4900105, doi: [10.1109/TASC.2023.3338142](https://ieeexplore.ieee.org/document/10337614).
35
+ - M. Wozniak et al, "Fast Quench Propagation Conductor for Protecting Canted Cos-Theta Magnets," in IEEE Transactions on Applied Superconductivity, vol. 33, no. 5, pp. 1-5, Aug. 2023, Art no. 4701705, doi: [10.1109/TASC.2023.3247997](https://ieeexplore.ieee.org/document/10050158).
36
+ - E. Schnaubelt et al, "Parallel-in-Time Integration of Transient Phenomena in No-Insulation Superconducting Coils Using Parareal", accepted for publication in the proceedings of the
37
+ Scientific Computing in Electrical Engineering (SCEE) 2024 conference, [arXiv:2404.13333](https://arxiv.org/abs/2404.13333).
38
+
39
+ ## Mathematical Formulations Forming the Basis of Some FiQuS Modules
40
+
41
+ - E. Schnaubelt et al, "Magneto-Thermal Thin Shell Approximation for 3D Finite Element Analysis of No-Insulation Coils", in IEEE Transactions on Applied Superconductivity, vol. 34, no. 3, pp. 1-6, Dec. 2023, Art no. 4700406, doi: [10.1109/TASC.2023.3340648](https://ieeexplore.ieee.org/document/10349801).
42
+ - E. Schnaubelt et al, "Electromagnetic Simulation of No-Insulation Coils Using H−φ Thin Shell Approximation", in IEEE Transactions on Applied Superconductivity, vol. 33, no. 5, pp. 1-6, Mar. 2023, Art no. 4900906, doi: [10.1109/TASC.2023.3258905](https://ieeexplore.ieee.org/document/10076826).
43
+ - E. Schnaubelt et al, "Thermal thin shell approximation towards finite element quench simulation", in Superconductor Science and Technology, vol. 36, no. 4, Art no. 044004, doi: [10.1088/1361-6668/acbeea](https://iopscience.iop.org/article/10.1088/1361-6668/acbeea).
44
+
45
+
46
+ # Folder Structure
47
+ ![FiQuS folder structure](https://gitlab.cern.ch/steam/fiqus/-/raw/master/docs/images/FiQuS_folder_structure.svg)
48
+
49
+ # Installation
50
+
51
+ ## Released version:
52
+ ```pip install fiqus```
53
+
54
+ # Links
55
+ STEAM website: http://cern.ch/steam
56
+
57
+ STEAM-FiQuS website: https://steam.docs.cern.ch/tools/fiqus/
58
+
59
+ STEAM-FiQuS documentation: https://steam-fiqus.docs.cern.ch/
60
+
61
+ Coverage report: https://steam-fiqus.docs.cern.ch/htmlcov/
62
+
63
+ # Contact
64
+ steam-team@cern.ch
65
+
66
+ # STEAM User Agreement
67
+ By using any software of the STEAM framework, users agree with this document:
68
+ https://edms.cern.ch/document/2024516
69
+
70
+ (Copyright © 2022, CERN, Switzerland. All rights reserved.)
@@ -0,0 +1,54 @@
1
+ ![FiQuS logo](https://gitlab.cern.ch/steam/fiqus/-/raw/master/docs/images/FiQuS_name_logo.svg)
2
+
3
+ # Introduction
4
+ Source code for STEAM **FiQuS** (**Fi**nite Element **Qu**ench **S**imulator).
5
+
6
+ # Publications
7
+
8
+ ## Describing FiQuS Modules
9
+ - S. Atalay et al, "An open-source 3D FE quench simulation tool for no-insulation HTS pancake coils", in Superconductor Science and Technology, doi: [10.1088/1361-6668/ad3f83](https://doi.org/10.1088/1361-6668/ad3f83)
10
+ - J. Dular et al, "Coupled Axial and Transverse Currents Method for Finite Element Modelling of Periodic Superconductors", arXiv preprint, doi:[10.48550/arXiv.2404.09775](https://doi.org/10.48550/arXiv.2404.09775).
11
+ - A. Vitrano et al, "An Open-Source Finite Element Quench Simulation Tool for Superconducting Magnets," in IEEE Transactions on Applied Superconductivity, vol. 33, no. 5, pp. 1-6, Aug. 2023, Art no. 4702006, doi: [10.1109/TASC.2023.3259332](https://ieeexplore.ieee.org/abstract/document/10077402).
12
+
13
+ ## Using FiQuS
14
+
15
+ - J. Dular et al, "Simulation of Rutherford Cable AC Loss and Magnetization with the Coupled Axial and Transverse Currents Method", accepted for publication in IEEE Transactions on Applied Superconductivity, [arXiv:2411.13347](https://arxiv.org/abs/2411.13347).
16
+ - M. Wozniak et al, "Influence of Critical Current Distribution on Operation, Quench Detection and Protection of HTS Pancake Coils, submitted for publication in IEEE Transactions on Applied Superconductivity, [arXiv:2411.18124](https://arxiv.org/abs/2411.18124).
17
+ - Laura AM D’Angelo et al, "Efficient Reduced Magnetic Vector Potential Formulation for the Magnetic Field Simulation of Accelerator Magnets", in IEEE Transactions on Magnetics, vol. 60, no. 3, pp. 1-8, Jan. 2024, Art no. 7000808, doi: [10.1109/TMAG.2024.3352113](https://ieeexplore.ieee.org/abstract/document/10387412).
18
+ - M. Wozniak et al, "Quench Co-Simulation of Canted Cos-Theta Magnets," in IEEE Transactions on Applied Superconductivity, vol. 34, no. 3, pp. 1-5, Dec. 2023, Art no. 4900105, doi: [10.1109/TASC.2023.3338142](https://ieeexplore.ieee.org/document/10337614).
19
+ - M. Wozniak et al, "Fast Quench Propagation Conductor for Protecting Canted Cos-Theta Magnets," in IEEE Transactions on Applied Superconductivity, vol. 33, no. 5, pp. 1-5, Aug. 2023, Art no. 4701705, doi: [10.1109/TASC.2023.3247997](https://ieeexplore.ieee.org/document/10050158).
20
+ - E. Schnaubelt et al, "Parallel-in-Time Integration of Transient Phenomena in No-Insulation Superconducting Coils Using Parareal", accepted for publication in the proceedings of the
21
+ Scientific Computing in Electrical Engineering (SCEE) 2024 conference, [arXiv:2404.13333](https://arxiv.org/abs/2404.13333).
22
+
23
+ ## Mathematical Formulations Forming the Basis of Some FiQuS Modules
24
+
25
+ - E. Schnaubelt et al, "Magneto-Thermal Thin Shell Approximation for 3D Finite Element Analysis of No-Insulation Coils", in IEEE Transactions on Applied Superconductivity, vol. 34, no. 3, pp. 1-6, Dec. 2023, Art no. 4700406, doi: [10.1109/TASC.2023.3340648](https://ieeexplore.ieee.org/document/10349801).
26
+ - E. Schnaubelt et al, "Electromagnetic Simulation of No-Insulation Coils Using H−φ Thin Shell Approximation", in IEEE Transactions on Applied Superconductivity, vol. 33, no. 5, pp. 1-6, Mar. 2023, Art no. 4900906, doi: [10.1109/TASC.2023.3258905](https://ieeexplore.ieee.org/document/10076826).
27
+ - E. Schnaubelt et al, "Thermal thin shell approximation towards finite element quench simulation", in Superconductor Science and Technology, vol. 36, no. 4, Art no. 044004, doi: [10.1088/1361-6668/acbeea](https://iopscience.iop.org/article/10.1088/1361-6668/acbeea).
28
+
29
+
30
+ # Folder Structure
31
+ ![FiQuS folder structure](https://gitlab.cern.ch/steam/fiqus/-/raw/master/docs/images/FiQuS_folder_structure.svg)
32
+
33
+ # Installation
34
+
35
+ ## Released version:
36
+ ```pip install fiqus```
37
+
38
+ # Links
39
+ STEAM website: http://cern.ch/steam
40
+
41
+ STEAM-FiQuS website: https://steam.docs.cern.ch/tools/fiqus/
42
+
43
+ STEAM-FiQuS documentation: https://steam-fiqus.docs.cern.ch/
44
+
45
+ Coverage report: https://steam-fiqus.docs.cern.ch/htmlcov/
46
+
47
+ # Contact
48
+ steam-team@cern.ch
49
+
50
+ # STEAM User Agreement
51
+ By using any software of the STEAM framework, users agree with this document:
52
+ https://edms.cern.ch/document/2024516
53
+
54
+ (Copyright © 2022, CERN, Switzerland. All rights reserved.)
@@ -0,0 +1,509 @@
1
+ import argparse
2
+ import csv
3
+ import os
4
+ import pathlib
5
+ import sys
6
+ import time
7
+ import getpass
8
+ import platform
9
+ import subprocess
10
+ import json
11
+
12
+ import pandas as pd
13
+
14
+ FiQuS_path = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
15
+ sys.path.insert(0, FiQuS_path)
16
+
17
+ from fiqus.utils.Utils import FilesAndFolders as Util
18
+ from fiqus.utils.Utils import CheckForExceptions as Check
19
+ from fiqus.utils.Utils import create_json_schema
20
+ from fiqus.utils.Utils import get_data_settings
21
+ from fiqus.utils.Utils import initialize_logger
22
+ from fiqus.data.DataFiQuS import FDM
23
+ from fiqus.data.DataSettings import DataSettings
24
+ from fiqus.mains.MainCCT import MainCCT
25
+ from fiqus.mains.MainMultipole import MainMultipole
26
+ from fiqus.mains.MainPancake3D import MainPancake3D
27
+ from fiqus.mains.MainConductorAC_Strand import MainConductorAC_Strand
28
+
29
+ class MainFiQuS:
30
+ """
31
+ This is the top level class of FiQuS.
32
+ """
33
+
34
+ def __init__(
35
+ self,
36
+ input_file_path: str = None,
37
+ model_folder: str = None,
38
+ GetDP_path=None,
39
+ fdm=None,
40
+ fds=None,
41
+ htcondor_jobid=None
42
+ ):
43
+ """
44
+ Main class for working with FiQuS simulations
45
+ :param input_file_path: full path to input file yaml
46
+ :type input_file_path: str
47
+ :param model_folder: full path to the base output folder, called model folder
48
+ :type model_folder: str
49
+ :param GetDP_path: full path to GetDP executable
50
+ :type GetDP_path: str
51
+ :param fdm: FiQuS Data Model - object of fiqus DataFiQus
52
+ :type fdm: object
53
+ :param fds: FiQuS Data Settings - object of DataSettings
54
+ :type fds: object
55
+ """
56
+ self.time_stamp = time.strftime("%Y-%m-%d-%H-%M-%S")
57
+
58
+ self.start_folder = os.getcwd()
59
+ self.wrk_folder = model_folder
60
+ self.file_name = None
61
+
62
+ # Load yaml input file
63
+ if not fdm:
64
+ self.fdm: FDM = Util.read_data_from_yaml(input_file_path, FDM)
65
+ copyInputFile = (
66
+ "copy"
67
+ f" {input_file_path} {os.path.join(self.wrk_folder, 'logs', f'INPUT_FILE_{self.time_stamp}.FiQuS.yaml')}"
68
+ )
69
+ subprocess.run(copyInputFile, shell=True, stdout=subprocess.DEVNULL)
70
+ else:
71
+ self.fdm: FDM = fdm
72
+ verbose = self.fdm.run.verbosity_FiQuS
73
+ self.logger = initialize_logger(
74
+ verbose=verbose, time_stamp=self.time_stamp, work_folder=self.wrk_folder
75
+ )
76
+ if verbose:
77
+ Util.print_welcome_graphics()
78
+ # Intialize logger
79
+
80
+ # Create JSON schema
81
+ create_json_schema(self.fdm)
82
+
83
+ # Check for input errors
84
+ Check.check_inputs(run=self.fdm.run)
85
+
86
+ # Initialize Main object
87
+ if self.fdm.magnet.type == "CCT_straight":
88
+ self.main_magnet = MainCCT(fdm=self.fdm, verbose=verbose)
89
+ elif self.fdm.magnet.type == "CWS":
90
+ self.main_magnet = MainCWS(
91
+ fdm=self.fdm,
92
+ inputs_folder_path=pathlib.Path(input_file_path).parent,
93
+ verbose=self.fdm.run.verbosity_FiQuS,
94
+ )
95
+ elif self.fdm.magnet.type == "Pancake3D":
96
+ self.main_magnet = MainPancake3D(fdm=self.fdm, verbose=verbose)
97
+ elif self.fdm.magnet.type == "CACStrand":
98
+ self.main_magnet = MainConductorAC_Strand(fdm=self.fdm, inputs_folder_path=pathlib.Path(input_file_path).parent, outputs_folder_path=model_folder, verbose=verbose)
99
+ elif self.fdm.magnet.type == "CACRutherford":
100
+ self.main_magnet = MainConductorAC_Rutherford(fdm=self.fdm, inputs_folder_path=pathlib.Path(input_file_path).parent, verbose=verbose)
101
+ elif self.fdm.magnet.type == "Racetrack":
102
+ self.main_magnet = MainRacetrack(fdm=self.fdm, verbose=verbose)
103
+ elif self.fdm.magnet.type == "Racetrack3D":
104
+ self.main_magnet = MainRacetrack3D(fdm=self.fdm, inputs_folder_path=pathlib.Path(input_file_path).parent, verbose=verbose)
105
+ elif self.fdm.magnet.type == "multipole":
106
+ self.file_name = os.path.basename(input_file_path)[:-5]
107
+ if not self.fdm.magnet.geometry.geom_file_path:
108
+ self.fdm.magnet.geometry.geom_file_path = f"{input_file_path[:-5]}.geom"
109
+ self.main_magnet = MainMultipole(
110
+ fdm=self.fdm,
111
+ rgd_path=self.fdm.magnet.geometry.geom_file_path,
112
+ verbose=verbose,
113
+ )
114
+
115
+ else:
116
+ raise ValueError(
117
+ f"FiQuS does not support magnet type: {self.fdm.magnet.type}!"
118
+ )
119
+
120
+ # Load user paths for executables and additional files
121
+ self.logger.info(f'{getpass.getuser()} is running on {platform.platform()}')
122
+ if not fds:
123
+ fds = get_data_settings(GetDP_path=GetDP_path)
124
+ else:
125
+ fds = get_data_settings(GetDP_path=GetDP_path, settings=fds)
126
+ self.main_magnet.GetDP_path = fds.GetDP_path
127
+ self.logger.info(f"{self.main_magnet.GetDP_path} is going to be used for FE solving.")
128
+
129
+ # self.logger.info(gmsh.onelab.run(self.fdm.general.magnet_name, f"{self.main_magnet.settings['GetDP_path']} -info"))
130
+
131
+ # update htcondor csv
132
+ if htcondor_jobid:
133
+ base_path_model_files = fds.base_path_model_files
134
+ htcondor_csv_file = os.path.join(base_path_model_files, "htcondor_run_log.csv")
135
+
136
+ self.change_htcondor_run_log(htcondor_csv_file, htcondor_jobid, "Running")
137
+
138
+ # Save Model/Geometry/Mesh/Solution folder paths
139
+ self.save_folders()
140
+
141
+ # Build magnet
142
+ self.summary = dict.fromkeys(
143
+ [
144
+ "SJ",
145
+ "SICN",
146
+ "SIGE",
147
+ "Gamma",
148
+ "nodes",
149
+ "solution_time",
150
+ "overall_error",
151
+ "minimum_diff",
152
+ "maximum_diff",
153
+ ]
154
+ )
155
+
156
+ try:
157
+ self.build_magnet()
158
+ except Exception as e:
159
+ # update htcondor csv
160
+ if htcondor_jobid:
161
+ self.change_htcondor_run_log(htcondor_csv_file, htcondor_jobid, "Failed")
162
+
163
+ self.logger.error(f"Error: {e}")
164
+ raise e
165
+ else:
166
+ # update htcondor csv
167
+ if htcondor_jobid:
168
+ self.change_htcondor_run_log(htcondor_csv_file, htcondor_jobid, "Finished")
169
+
170
+ def save_folders(self):
171
+ """
172
+ Method to make or delete folders of FiQuS
173
+ :return: Nothing, only does file and folder operation
174
+ :rtype: None
175
+ """
176
+ def _check_and_generate_path(folder_type: str = None):
177
+ if folder_type == "Geometry":
178
+ folder = self.wrk_folder
179
+ elif folder_type == "Mesh":
180
+ folder = self.main_magnet.geom_folder
181
+ elif folder_type == "Solution":
182
+ folder = self.main_magnet.mesh_folder
183
+ else:
184
+ raise Exception("Incompatible type.")
185
+
186
+ if getattr(self.fdm.run, folder_type.lower()) is None:
187
+ # folder_key is not given, so it is computed
188
+ folder_key = Util.compute_folder_key(
189
+ folder_type=folder_type,
190
+ folder=folder,
191
+ overwrite=self.fdm.run.overwrite,
192
+ )
193
+ else:
194
+ # folder_key is given
195
+ folder_key = getattr(self.fdm.run, folder_type.lower())
196
+
197
+ required_folder = folder_type in required_folders
198
+ if self.fdm.run.overwrite and folder_type == (
199
+ required_folders[0] if required_folders else None
200
+ ):
201
+ Check.check_overwrite_conditions(
202
+ folder_type=folder_type, folder=folder, folder_key=folder_key
203
+ )
204
+ return Util.get_folder_path(
205
+ folder_type=folder_type,
206
+ folder=folder,
207
+ folder_key=folder_key,
208
+ overwrite=self.fdm.run.overwrite,
209
+ required_folder=required_folder,
210
+ )
211
+
212
+ if self.fdm.run.type == "start_from_yaml":
213
+ required_folders = ["Geometry", "Mesh", "Solution"]
214
+ elif self.fdm.run.type == "geometry_and_mesh":
215
+ required_folders = ["Geometry", "Mesh"]
216
+ elif self.fdm.run.type == "mesh_and_solve_with_post_process_python":
217
+ required_folders = ["Mesh", "Solution"]
218
+ elif self.fdm.run.type in ["solve_with_post_process_python", "solve_only"]:
219
+ required_folders = ["Solution"]
220
+ elif self.fdm.run.type == "geometry_only":
221
+ required_folders = (
222
+ []
223
+ if self.fdm.run.geometry and not self.fdm.run.overwrite
224
+ else ["Geometry"]
225
+ )
226
+ elif self.fdm.run.type == "mesh_only":
227
+ required_folders = (
228
+ [] if self.fdm.run.mesh and not self.fdm.run.overwrite else ["Mesh"]
229
+ )
230
+ else: # post_process_getdp_only or post_process_python_only or plot_python
231
+ required_folders = []
232
+
233
+ fdm = self.main_magnet.fdm.magnet
234
+
235
+ self.main_magnet.geom_folder = _check_and_generate_path(folder_type="Geometry")
236
+ if not self.fdm.run.type in ["geometry_only"]:
237
+ self.main_magnet.mesh_folder = _check_and_generate_path(folder_type="Mesh")
238
+ if not (
239
+ self.fdm.run.type == "geometry_only"
240
+ or self.fdm.run.type == "mesh_only"
241
+ ):
242
+ self.main_magnet.solution_folder = _check_and_generate_path(
243
+ folder_type="Solution"
244
+ )
245
+
246
+ if self.fdm.run.type in [
247
+ "start_from_yaml",
248
+ "geometry_and_mesh",
249
+ "geometry_only",
250
+ ]:
251
+ Util.write_data_model_to_yaml(
252
+ os.path.join(self.main_magnet.geom_folder, "geometry.yaml"),
253
+ fdm.geometry,
254
+ by_alias=True,
255
+ with_comments=True,
256
+ )
257
+ if self.fdm.run.type in [
258
+ "start_from_yaml",
259
+ "geometry_and_mesh",
260
+ "mesh_and_solve_with_post_process_python",
261
+ "mesh_only",
262
+ ]:
263
+ Util.write_data_model_to_yaml(
264
+ os.path.join(self.main_magnet.mesh_folder, "mesh.yaml"),
265
+ fdm.mesh,
266
+ by_alias=True,
267
+ with_comments=True,
268
+ )
269
+ if self.fdm.run.type in [
270
+ "start_from_yaml",
271
+ "mesh_and_solve_with_post_process_python",
272
+ "solve_with_post_process_python",
273
+ "solve_only",
274
+ "post_process",
275
+ "plot_python"
276
+ ]:
277
+ Util.write_data_model_to_yaml(
278
+ os.path.join(self.main_magnet.solution_folder, "solve.yaml"),
279
+ fdm.solve,
280
+ by_alias=True,
281
+ with_comments=True,
282
+ )
283
+ if self.fdm.run.type in [
284
+ "start_from_yaml",
285
+ "mesh_and_solve_with_post_process_python",
286
+ "solve_with_post_process_python",
287
+ "post_process_python_only",
288
+ "post_process_getdp_only",
289
+ "post_process",
290
+ "plot_python"
291
+ ]:
292
+ Util.write_data_model_to_yaml(
293
+ os.path.join(self.main_magnet.solution_folder, "postproc.yaml"),
294
+ fdm.postproc,
295
+ by_alias=True,
296
+ with_comments=True,
297
+ )
298
+
299
+ try:
300
+ run_type = self.fdm.run.type
301
+ comments = self.fdm.run.comments
302
+ if self.main_magnet.geom_folder is not None:
303
+ geo_folder = os.path.relpath(self.main_magnet.geom_folder)
304
+ geo_folder = os.path.relpath(
305
+ geo_folder, os.path.join("tests", "_outputs")
306
+ )
307
+ else:
308
+ geo_folder = "-"
309
+
310
+ if self.main_magnet.mesh_folder is not None:
311
+ mesh_folder = os.path.relpath(self.main_magnet.mesh_folder)
312
+ mesh_folder = os.path.relpath(
313
+ mesh_folder, os.path.join("tests", "_outputs")
314
+ )
315
+ else:
316
+ mesh_folder = "-"
317
+
318
+ if self.main_magnet.solution_folder is not None:
319
+ solution_folder = os.path.relpath(self.main_magnet.solution_folder)
320
+ solution_folder = os.path.relpath(
321
+ solution_folder, os.path.join("tests", "_outputs")
322
+ )
323
+ else:
324
+ solution_folder = "-"
325
+
326
+ run_log_row = [
327
+ self.time_stamp,
328
+ run_type,
329
+ comments,
330
+ geo_folder,
331
+ mesh_folder,
332
+ solution_folder,
333
+ ]
334
+ self.add_to_run_log(
335
+ os.path.join(self.wrk_folder, "run_log.csv"), run_log_row
336
+ )
337
+ except:
338
+ self.logger.warning("Run log could not be completed.")
339
+
340
+ def build_magnet(self):
341
+ """
342
+ Main method to build magnets, i.e. to run various fiqus run types and magnet types
343
+ :return: none
344
+ :rtype: none
345
+ """
346
+ if self.fdm.run.type == "start_from_yaml":
347
+ self.main_magnet.generate_geometry()
348
+ self.main_magnet.pre_process()
349
+ self.main_magnet.load_geometry()
350
+ for key, value in self.main_magnet.mesh().items():
351
+ self.summary[key] = value
352
+ self.summary["solution_time"] = self.main_magnet.solve_and_postprocess_getdp()
353
+ for key, value in self.main_magnet.post_process_python(gui=self.main_magnet.fdm.run.launch_gui).items():
354
+ self.summary[key] = value
355
+ elif self.fdm.run.type == "pre_process_only":
356
+ self.main_magnet.pre_process()
357
+ for key, value in self.main_magnet.post_process_python(gui=self.main_magnet.fdm.run.launch_gui).items():
358
+ self.summary[key] = value # todo: DISABLE FOR ONE GROUP ONLY
359
+ elif self.fdm.run.type == "geometry_only":
360
+ self.main_magnet.generate_geometry(
361
+ gui=(self.main_magnet.fdm.run.launch_gui if self.fdm.magnet.type != "CCT_straight" else False)
362
+ )
363
+ if self.fdm.magnet.type in ["CCT_straight", "CWS"]:
364
+ self.main_magnet.pre_process(gui=self.main_magnet.fdm.run.launch_gui)
365
+ elif self.fdm.run.type == "geometry_and_mesh":
366
+ self.main_magnet.generate_geometry()
367
+ self.main_magnet.pre_process()
368
+ self.main_magnet.load_geometry()
369
+ for key, value in self.main_magnet.mesh(gui=self.main_magnet.fdm.run.launch_gui).items():
370
+ self.summary[key] = value
371
+ elif self.fdm.run.type == "mesh_and_solve_with_post_process_python":
372
+ self.main_magnet.load_geometry()
373
+ for key, value in self.main_magnet.mesh().items():
374
+ self.summary[key] = value
375
+ self.summary["solution_time"] = self.main_magnet.solve_and_postprocess_getdp()
376
+ for key, value in self.main_magnet.post_process_python(gui=self.main_magnet.fdm.run.launch_gui).items():
377
+ self.summary[key] = value
378
+ elif self.fdm.run.type == "mesh_only":
379
+ self.main_magnet.load_geometry()
380
+ for key, value in self.main_magnet.mesh(gui=self.main_magnet.fdm.run.launch_gui).items():
381
+ self.summary[key] = value
382
+ elif self.fdm.run.type == "solve_with_post_process_python":
383
+ self.summary["solution_time"] = (
384
+ self.main_magnet.solve_and_postprocess_getdp(gui=self.main_magnet.fdm.run.launch_gui)
385
+ )
386
+ for key, value in self.main_magnet.post_process_python(gui=self.main_magnet.fdm.run.launch_gui).items():
387
+ self.summary[key] = value
388
+ elif self.fdm.run.type == "solve_only":
389
+ self.summary["solution_time"] = (
390
+ self.main_magnet.solve_and_postprocess_getdp(gui=self.main_magnet.fdm.run.launch_gui)
391
+ )
392
+ elif self.fdm.run.type == "post_process_getdp_only":
393
+ self.main_magnet.post_process_getdp(gui=self.main_magnet.fdm.run.launch_gui)
394
+ elif self.fdm.run.type == "post_process_python_only":
395
+ for key, value in self.main_magnet.post_process_python(gui=self.main_magnet.fdm.run.launch_gui).items():
396
+ self.summary[key] = value
397
+ elif self.fdm.run.type == "post_process":
398
+ self.main_magnet.post_process_getdp(gui=self.main_magnet.fdm.run.launch_gui)
399
+ for key, value in self.main_magnet.post_process_python(gui=self.main_magnet.fdm.run.launch_gui).items():
400
+ self.summary[key] = value
401
+ elif self.fdm.run.type == "plot_python":
402
+ self.main_magnet.plot_python()
403
+
404
+ elif self.fdm.run.type == "batch_post_process_python":
405
+ self.main_magnet.batch_post_process_python()
406
+ os.chdir(self.start_folder)
407
+
408
+ if self.file_name: json.dump(self.summary, open(f"{os.path.join(self.wrk_folder, self.file_name)}.json", 'w'))
409
+ # mesh_par = self.fdm.magnet.mesh
410
+ # if self.summary['solution_time']:
411
+ # with open(r"C:\Users\avitrano\PycharmProjects\steam_sdk\tests\parsims\FiQuS_run\summary.dat", 'a') as f:
412
+ # content = (f"{mesh_par.mesh_coil.SizeMin} {mesh_par.mesh_coil.SizeMax} {mesh_par.mesh_iron.SizeMin} {mesh_par.mesh_iron.SizeMax} "
413
+ # f"{self.summary['solution_time']} {self.summary['overall_error']} {self.summary['overall_error'] * 0.999 + self.summary['solution_time'] * 0.001} "
414
+ # f"{self.summary['SJ']} {self.summary['SICN']} {self.summary['SIGE']} {self.summary['Gamma']} "
415
+ # f"{self.summary['nodes']} {self.summary['minimum_diff']} {self.summary['maximum_diff']}\n")
416
+ # f.writelines(content)
417
+
418
+ @staticmethod
419
+ def add_to_run_log(path_to_csv, run_log_row):
420
+ # If file does not exist, write the header
421
+ if not os.path.isfile(path_to_csv):
422
+ header = [
423
+ "Time Stamp",
424
+ "Run Type",
425
+ "Comments",
426
+ "Geometry Directory",
427
+ "Mesh Directory",
428
+ "Solution Directory",
429
+ ]
430
+ with open(path_to_csv, "a", newline="") as csv_file:
431
+ writer = csv.writer(csv_file)
432
+ writer.writerow(header)
433
+
434
+ # Open the CSV file in append mode
435
+ with open(path_to_csv, "a+", newline="") as csv_file:
436
+ writer = csv.writer(csv_file)
437
+ writer.writerow(run_log_row)
438
+
439
+ def change_htcondor_run_log(self, htcondor_csv_file, htcondor_jobid, new_status="None"):
440
+ try:
441
+ df = pd.read_csv(htcondor_csv_file)
442
+ df.loc[df['Job ID'] == htcondor_jobid, 'Status'] = str(new_status)
443
+ self.logger.info(f"Changed status of JobID {htcondor_jobid} to {new_status} in {htcondor_csv_file}.")
444
+ df.to_csv(htcondor_csv_file, index=False)
445
+ except:
446
+ self.logger.warning(f"Could not change status of JobID {htcondor_jobid} to {new_status} in {htcondor_csv_file}.")
447
+
448
+ if __name__ == "__main__":
449
+ parser = argparse.ArgumentParser(
450
+ prog="FiQuS",
451
+ description="Finite Elements Quench Simulator",
452
+ epilog="steam-team@cern.ch",
453
+ )
454
+ parser.add_argument(
455
+ dest="full_path_input",
456
+ type=str,
457
+ help="Full path to FiQuS input yaml file",
458
+ )
459
+ parser.add_argument(
460
+ "--output", '-o', dest="output_path", type=str, help="Full path to FiQuS output folder"
461
+ )
462
+ parser.add_argument(
463
+ "--getdp", '-g', dest="GetDP_path", type=str, help="Full path to GetDP executable"
464
+ )
465
+
466
+ parser.add_argument("--htcondor_jobid", '-j', type=int, default=0,
467
+ help="HTCondor job ID (optional)", required=False)
468
+
469
+ parser.add_argument("--fiqus_data_model", '-m', type=str,
470
+ help="Full path to FiQuS Data Model file (optional)", required=False)
471
+
472
+ parser.add_argument("--fiqus_data_settings", '-s', type=str,
473
+ help="Full path to FiQuS Data Settings file (optional)", required=False)
474
+
475
+ args, unknown = parser.parse_known_args()
476
+
477
+ # remove these options from sys.argv, otherwise they are passed onto Gmsh
478
+ # in Gmsh.initialize()
479
+ options_to_remove = ["-o", "-g", "-j", "-m", "-s"]
480
+ # Loop through and remove each option and its value
481
+ i = 0
482
+ while i < len(sys.argv):
483
+ if sys.argv[i] in options_to_remove:
484
+ sys.argv.pop(i) # Remove the option
485
+ if i < len(sys.argv):
486
+ sys.argv.pop(i) # Remove the associated value
487
+ else:
488
+ i += 1
489
+
490
+ if args.fiqus_data_model != None and args.fiqus_data_settings != None:
491
+ # read fdm and fds from a file (HTCondor case)
492
+ input_fdm = Util.read_data_from_yaml(args.fiqus_data_model, FDM)
493
+ input_fds = Util.read_data_from_yaml(args.fiqus_data_settings, DataSettings)
494
+
495
+ MainFiQuS(
496
+ input_file_path=args.full_path_input,
497
+ model_folder=args.output_path,
498
+ fdm=input_fdm,
499
+ fds=input_fds,
500
+ htcondor_jobid=args.htcondor_jobid
501
+ )
502
+ else:
503
+ # fdm and fds from input (STEAM SDK case)
504
+ MainFiQuS(
505
+ input_file_path=args.full_path_input,
506
+ model_folder=args.output_path,
507
+ GetDP_path=args.GetDP_path,
508
+ )
509
+ print("FiQuS run completed")