ansys-fluent-core 0.29.dev0__py3-none-any.whl → 0.29.dev2__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 ansys-fluent-core might be problematic. Click here for more details.
- ansys/fluent/core/__init__.py +1 -1
- ansys/fluent/core/_version.py +2 -2
- ansys/fluent/core/codegen/tuigen.py +1 -1
- ansys/fluent/core/codegen/walk_api.py +45 -18
- ansys/fluent/core/generated/api_tree/api_objects.json +1 -1
- ansys/fluent/core/generated/datamodel_252/meshing.py +1 -0
- ansys/fluent/core/generated/datamodel_252/preferences.py +7 -0
- ansys/fluent/core/generated/fluent_version_252.py +3 -3
- ansys/fluent/core/generated/meshing/tui_252.py +395 -390
- ansys/fluent/core/generated/solver/settings_252.py +782 -306
- ansys/fluent/core/generated/solver/settings_252.pyi +442 -133
- ansys/fluent/core/generated/solver/tui_252.py +4046 -3737
- ansys/fluent/core/launcher/container_launcher.py +4 -3
- ansys/fluent/core/launcher/fluent_container.py +22 -19
- ansys/fluent/core/launcher/launcher.py +2 -2
- ansys/fluent/core/launcher/pim_launcher.py +2 -2
- ansys/fluent/core/launcher/slurm_launcher.py +2 -2
- ansys/fluent/core/launcher/standalone_launcher.py +2 -2
- ansys/fluent/core/logging.py +2 -0
- ansys/fluent/core/logging_config.yaml +3 -0
- ansys/fluent/core/services/app_utilities.py +2 -1
- ansys/fluent/core/services/datamodel_se.py +141 -61
- ansys/fluent/core/services/field_data.py +252 -0
- ansys/fluent/core/services/interceptors.py +28 -2
- ansys/fluent/core/session.py +7 -2
- ansys/fluent/core/session_solver.py +21 -0
- ansys/fluent/core/streaming_services/datamodel_event_streaming.py +12 -12
- {ansys_fluent_core-0.29.dev0.dist-info → ansys_fluent_core-0.29.dev2.dist-info}/LICENSE +1 -1
- {ansys_fluent_core-0.29.dev0.dist-info → ansys_fluent_core-0.29.dev2.dist-info}/METADATA +53 -31
- {ansys_fluent_core-0.29.dev0.dist-info → ansys_fluent_core-0.29.dev2.dist-info}/RECORD +65 -141
- {ansys_fluent_core-0.29.dev0.dist-info → ansys_fluent_core-0.29.dev2.dist-info}/WHEEL +1 -1
- ansys/fluent/core/docs/README.rst +0 -155
- ansys/fluent/tests/conftest.py +0 -415
- ansys/fluent/tests/fluent_fixtures.py +0 -195
- ansys/fluent/tests/integration/test_optislang/test_optislang_integration.py +0 -263
- ansys/fluent/tests/parametric/test_local_parametric_run.py +0 -36
- ansys/fluent/tests/parametric/test_local_parametric_setup.py +0 -34
- ansys/fluent/tests/parametric/test_parametric_workflow.py +0 -279
- ansys/fluent/tests/test_aero_session.py +0 -88
- ansys/fluent/tests/test_batch_ops.py +0 -39
- ansys/fluent/tests/test_builtin_settings.py +0 -761
- ansys/fluent/tests/test_cad_to_post_ftm.py +0 -525
- ansys/fluent/tests/test_cad_to_post_wtm.py +0 -250
- ansys/fluent/tests/test_casereader.py +0 -324
- ansys/fluent/tests/test_codegen.py +0 -783
- ansys/fluent/tests/test_creatable.py +0 -31
- ansys/fluent/tests/test_data_model_cache.py +0 -434
- ansys/fluent/tests/test_datamodel_api.py +0 -449
- ansys/fluent/tests/test_datamodel_service.py +0 -814
- ansys/fluent/tests/test_datareader.py +0 -103
- ansys/fluent/tests/test_error_handling.py +0 -24
- ansys/fluent/tests/test_events_manager.py +0 -214
- ansys/fluent/tests/test_field_data.py +0 -466
- ansys/fluent/tests/test_file_session.py +0 -355
- ansys/fluent/tests/test_file_transfer_service.py +0 -165
- ansys/fluent/tests/test_fix_doc.py +0 -29
- ansys/fluent/tests/test_flobject.py +0 -1235
- ansys/fluent/tests/test_fluent_fixes.py +0 -106
- ansys/fluent/tests/test_fluent_session.py +0 -270
- ansys/fluent/tests/test_fluent_version.py +0 -66
- ansys/fluent/tests/test_fluent_version_marker.py +0 -65
- ansys/fluent/tests/test_icing_session.py +0 -9
- ansys/fluent/tests/test_launcher.py +0 -529
- ansys/fluent/tests/test_launcher_remote.py +0 -272
- ansys/fluent/tests/test_lispy.py +0 -40
- ansys/fluent/tests/test_logging.py +0 -16
- ansys/fluent/tests/test_mapped_api.py +0 -774
- ansys/fluent/tests/test_meshing_utilities.py +0 -2436
- ansys/fluent/tests/test_meshing_workflow.py +0 -421
- ansys/fluent/tests/test_meshingmode/test_meshing_launch.py +0 -168
- ansys/fluent/tests/test_new_meshing_workflow.py +0 -1801
- ansys/fluent/tests/test_preferences.py +0 -89
- ansys/fluent/tests/test_pure_mesh_vs_mesh_workflow.py +0 -101
- ansys/fluent/tests/test_reduction.py +0 -484
- ansys/fluent/tests/test_rp_vars.py +0 -77
- ansys/fluent/tests/test_scheduler.py +0 -471
- ansys/fluent/tests/test_scheme_eval_222.py +0 -338
- ansys/fluent/tests/test_scheme_eval_231.py +0 -243
- ansys/fluent/tests/test_search.py +0 -344
- ansys/fluent/tests/test_session.py +0 -594
- ansys/fluent/tests/test_settings_api.py +0 -606
- ansys/fluent/tests/test_settings_reader.py +0 -85
- ansys/fluent/tests/test_slurm_future.py +0 -67
- ansys/fluent/tests/test_solution_variables.py +0 -241
- ansys/fluent/tests/test_solver_monitors.py +0 -83
- ansys/fluent/tests/test_solvermode/boundaries_periodic_expDict +0 -1712
- ansys/fluent/tests/test_solvermode/test_boundaries.py +0 -127
- ansys/fluent/tests/test_solvermode/test_calculationactivities.py +0 -20
- ansys/fluent/tests/test_solvermode/test_controls.py +0 -131
- ansys/fluent/tests/test_solvermode/test_general.py +0 -109
- ansys/fluent/tests/test_solvermode/test_initialization.py +0 -83
- ansys/fluent/tests/test_solvermode/test_materials.py +0 -40
- ansys/fluent/tests/test_solvermode/test_methods.py +0 -65
- ansys/fluent/tests/test_solvermode/test_models.py +0 -99
- ansys/fluent/tests/test_solvermode/test_named_expressions.py +0 -35
- ansys/fluent/tests/test_solvermode/test_post_vector.py +0 -22
- ansys/fluent/tests/test_solvermode/test_species_model.py +0 -67
- ansys/fluent/tests/test_streaming_services.py +0 -52
- ansys/fluent/tests/test_systemcoupling.py +0 -44
- ansys/fluent/tests/test_topy.py +0 -179
- ansys/fluent/tests/test_tui_api.py +0 -70
- ansys/fluent/tests/test_type_stub.py +0 -37
- ansys/fluent/tests/test_utils.py +0 -82
- ansys/fluent/tests/util/__init__.py +0 -36
- ansys/fluent/tests/util/meshing_workflow.py +0 -33
- ansys/fluent/tests/util/solver.py +0 -72
- ansys_fluent_core-0.29.dev0.dist-info/AUTHORS +0 -12
|
@@ -1,606 +0,0 @@
|
|
|
1
|
-
import warnings
|
|
2
|
-
|
|
3
|
-
import pytest
|
|
4
|
-
from pytest import WarningsRecorder
|
|
5
|
-
|
|
6
|
-
from ansys.fluent.core.examples import download_file
|
|
7
|
-
from ansys.fluent.core.solver.flobject import (
|
|
8
|
-
DeprecatedSettingWarning,
|
|
9
|
-
UnstableSettingWarning,
|
|
10
|
-
_Alias,
|
|
11
|
-
_InputFile,
|
|
12
|
-
_OutputFile,
|
|
13
|
-
to_python_name,
|
|
14
|
-
)
|
|
15
|
-
from ansys.fluent.core.utils.execution import timeout_loop
|
|
16
|
-
from ansys.fluent.core.utils.fluent_version import FluentVersion
|
|
17
|
-
from ansys.fluent.core.warnings import PyFluentUserWarning
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
@pytest.mark.nightly
|
|
21
|
-
@pytest.mark.fluent_version(">=23.1")
|
|
22
|
-
def test_setup_models_viscous_model_settings(new_solver_session) -> None:
|
|
23
|
-
solver_session = new_solver_session
|
|
24
|
-
case_path = download_file("elbow_source_terms.cas.h5", "pyfluent/mixing_elbow")
|
|
25
|
-
solver_session.file.read(
|
|
26
|
-
file_name=case_path, file_type="case", lightweight_setup=True
|
|
27
|
-
)
|
|
28
|
-
|
|
29
|
-
viscous_model = solver_session.setup.models.viscous
|
|
30
|
-
|
|
31
|
-
assert viscous_model.model() == "k-epsilon"
|
|
32
|
-
assert "inviscid" in viscous_model.model.get_attr("allowed-values")
|
|
33
|
-
viscous_model.model = "inviscid"
|
|
34
|
-
|
|
35
|
-
assert viscous_model.model() == "inviscid"
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
# Failing for 24.1 but passes for 24.2 and 25.1
|
|
39
|
-
@pytest.mark.fluent_version(">=24.2")
|
|
40
|
-
def test_wildcard(new_solver_session):
|
|
41
|
-
solver = new_solver_session
|
|
42
|
-
case_path = download_file("elbow_source_terms.cas.h5", "pyfluent/mixing_elbow")
|
|
43
|
-
solver.file.read(file_name=case_path, file_type="case", lightweight_setup=True)
|
|
44
|
-
boundary_conditions = solver.setup.boundary_conditions
|
|
45
|
-
if solver.get_fluent_version() >= FluentVersion.v251:
|
|
46
|
-
assert boundary_conditions.velocity_inlet[
|
|
47
|
-
"inl*"
|
|
48
|
-
].momentum.velocity_magnitude() == {
|
|
49
|
-
"inlet2": {
|
|
50
|
-
"momentum": {"velocity_magnitude": {"option": "value", "value": 15}}
|
|
51
|
-
},
|
|
52
|
-
"inlet1": {
|
|
53
|
-
"momentum": {"velocity_magnitude": {"option": "value", "value": 5}}
|
|
54
|
-
},
|
|
55
|
-
}
|
|
56
|
-
assert boundary_conditions.velocity_inlet[
|
|
57
|
-
"inl*"
|
|
58
|
-
].momentum.velocity_magnitude.value() == {
|
|
59
|
-
"inlet2": {"momentum": {"velocity_magnitude": {"value": 15}}},
|
|
60
|
-
"inlet1": {"momentum": {"velocity_magnitude": {"value": 5}}},
|
|
61
|
-
}
|
|
62
|
-
boundary_conditions.velocity_inlet["inl*"].momentum.velocity_magnitude = 10
|
|
63
|
-
assert boundary_conditions.velocity_inlet[
|
|
64
|
-
"inl*"
|
|
65
|
-
].momentum.velocity_magnitude() == {
|
|
66
|
-
"inlet2": {
|
|
67
|
-
"momentum": {"velocity_magnitude": {"option": "value", "value": 10}}
|
|
68
|
-
},
|
|
69
|
-
"inlet1": {
|
|
70
|
-
"momentum": {"velocity_magnitude": {"option": "value", "value": 10}}
|
|
71
|
-
},
|
|
72
|
-
}
|
|
73
|
-
boundary_conditions.velocity_inlet = boundary_conditions.velocity_inlet[
|
|
74
|
-
"inl*"
|
|
75
|
-
].momentum.velocity_magnitude()
|
|
76
|
-
assert boundary_conditions.velocity_inlet[
|
|
77
|
-
"inl*"
|
|
78
|
-
].momentum.velocity_magnitude() == {
|
|
79
|
-
"inlet2": {
|
|
80
|
-
"momentum": {"velocity_magnitude": {"option": "value", "value": 10}}
|
|
81
|
-
},
|
|
82
|
-
"inlet1": {
|
|
83
|
-
"momentum": {"velocity_magnitude": {"option": "value", "value": 10}}
|
|
84
|
-
},
|
|
85
|
-
}
|
|
86
|
-
state = boundary_conditions.velocity_inlet["inl*"]()
|
|
87
|
-
assert state["inlet1"]["momentum"]["velocity_magnitude"]["value"] == 10
|
|
88
|
-
assert state["inlet2"]["momentum"]["velocity_magnitude"]["value"] == 10
|
|
89
|
-
boundary_conditions.velocity_inlet["inl*"] = {
|
|
90
|
-
"momentum": {"velocity_magnitude": {"value": 15}}
|
|
91
|
-
}
|
|
92
|
-
state = boundary_conditions.velocity_inlet["inl*"]()
|
|
93
|
-
assert state["inlet1"]["momentum"]["velocity_magnitude"]["value"] == 15
|
|
94
|
-
assert state["inlet2"]["momentum"]["velocity_magnitude"]["value"] == 15
|
|
95
|
-
else:
|
|
96
|
-
assert boundary_conditions.velocity_inlet["inl*"].momentum.velocity() == {
|
|
97
|
-
"inlet2": {"momentum": {"velocity": {"option": "value", "value": 15}}},
|
|
98
|
-
"inlet1": {"momentum": {"velocity": {"option": "value", "value": 5}}},
|
|
99
|
-
}
|
|
100
|
-
assert boundary_conditions.velocity_inlet["inl*"].momentum.velocity.value() == {
|
|
101
|
-
"inlet2": {"momentum": {"velocity": {"value": 15}}},
|
|
102
|
-
"inlet1": {"momentum": {"velocity": {"value": 5}}},
|
|
103
|
-
}
|
|
104
|
-
boundary_conditions.velocity_inlet["inl*"].momentum.velocity = 10
|
|
105
|
-
assert boundary_conditions.velocity_inlet["inl*"].momentum.velocity() == {
|
|
106
|
-
"inlet2": {"momentum": {"velocity": {"option": "value", "value": 10}}},
|
|
107
|
-
"inlet1": {"momentum": {"velocity": {"option": "value", "value": 10}}},
|
|
108
|
-
}
|
|
109
|
-
boundary_conditions.velocity_inlet = boundary_conditions.velocity_inlet[
|
|
110
|
-
"inl*"
|
|
111
|
-
].momentum.velocity()
|
|
112
|
-
assert boundary_conditions.velocity_inlet["inl*"].momentum.velocity() == {
|
|
113
|
-
"inlet2": {"momentum": {"velocity": {"option": "value", "value": 10}}},
|
|
114
|
-
"inlet1": {"momentum": {"velocity": {"option": "value", "value": 10}}},
|
|
115
|
-
}
|
|
116
|
-
cell_zone_conditions = solver.setup.cell_zone_conditions
|
|
117
|
-
if solver.get_fluent_version() >= FluentVersion.v242:
|
|
118
|
-
sources = cell_zone_conditions.fluid["*"].sources.terms
|
|
119
|
-
sources_key = "sources"
|
|
120
|
-
terms_key = "terms"
|
|
121
|
-
else:
|
|
122
|
-
sources = cell_zone_conditions.fluid["*"].source_terms.source_terms
|
|
123
|
-
sources_key = terms_key = "source_terms"
|
|
124
|
-
assert sources["*mom*"]() == {
|
|
125
|
-
"fluid": {
|
|
126
|
-
sources_key: {
|
|
127
|
-
terms_key: {
|
|
128
|
-
"x-momentum": [{"option": "value", "value": 1}],
|
|
129
|
-
"y-momentum": [{"option": "value", "value": 2}],
|
|
130
|
-
"z-momentum": [{"option": "value", "value": 3}],
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
}
|
|
134
|
-
}
|
|
135
|
-
sources["*mom*"] = [{"option": "value", "value": 2}]
|
|
136
|
-
assert sources["*mom*"]() == {
|
|
137
|
-
"fluid": {
|
|
138
|
-
sources_key: {
|
|
139
|
-
terms_key: {
|
|
140
|
-
"x-momentum": [{"option": "value", "value": 2}],
|
|
141
|
-
"y-momentum": [{"option": "value", "value": 2}],
|
|
142
|
-
"z-momentum": [{"option": "value", "value": 2}],
|
|
143
|
-
}
|
|
144
|
-
}
|
|
145
|
-
}
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
with pytest.raises(AttributeError):
|
|
149
|
-
boundary_conditions.velocity_inlet["inl*"].moment
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
@pytest.mark.fluent_version(">=23.2")
|
|
153
|
-
def test_wildcard_fnmatch(new_solver_session):
|
|
154
|
-
solver = new_solver_session
|
|
155
|
-
case_path = download_file("elbow_source_terms.cas.h5", "pyfluent/mixing_elbow")
|
|
156
|
-
solver.file.read_case(file_name=case_path)
|
|
157
|
-
|
|
158
|
-
solver.solution.initialization.hybrid_initialize()
|
|
159
|
-
|
|
160
|
-
mesh = solver.results.graphics.mesh
|
|
161
|
-
assert mesh.create("mesh-a").name() == "mesh-a"
|
|
162
|
-
mesh.create("mesh-bc")
|
|
163
|
-
if solver.get_fluent_version() >= FluentVersion.v251:
|
|
164
|
-
assert mesh.create(name="mesh-2").name() == "mesh-2"
|
|
165
|
-
assert mesh.create().name() == "mesh-3"
|
|
166
|
-
else:
|
|
167
|
-
assert mesh.create("mesh-2").name() == "mesh-2"
|
|
168
|
-
assert mesh.create("mesh-3").name() == "mesh-3"
|
|
169
|
-
|
|
170
|
-
assert sorted(mesh["mesh-*"]()) == sorted(
|
|
171
|
-
["mesh-1", "mesh-2", "mesh-3", "mesh-a", "mesh-bc"]
|
|
172
|
-
)
|
|
173
|
-
|
|
174
|
-
assert list(mesh["mesh-?c"]().keys()) == ["mesh-bc"]
|
|
175
|
-
|
|
176
|
-
assert list(mesh["mesh-[2-5]"]().keys()) == ["mesh-2", "mesh-3"]
|
|
177
|
-
|
|
178
|
-
assert sorted(mesh["mesh-[!2-5]"]()) == sorted(["mesh-1", "mesh-a"])
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
@pytest.mark.fluent_version(">=23.2")
|
|
182
|
-
def test_wildcard_path_is_iterable(new_solver_session):
|
|
183
|
-
solver = new_solver_session
|
|
184
|
-
case_path = download_file("elbow_source_terms.cas.h5", "pyfluent/mixing_elbow")
|
|
185
|
-
solver.file.read(file_name=case_path, file_type="case", lightweight_setup=True)
|
|
186
|
-
|
|
187
|
-
velocity_inlet = solver.setup.boundary_conditions.velocity_inlet
|
|
188
|
-
assert [x for x in velocity_inlet] == ["inlet2", "inlet1"]
|
|
189
|
-
assert [x for x in velocity_inlet["*let*"]] == ["inlet2", "inlet1"]
|
|
190
|
-
assert [x for x in velocity_inlet["*1*"]] == ["inlet1"]
|
|
191
|
-
|
|
192
|
-
test_data = []
|
|
193
|
-
for k, v in velocity_inlet.items():
|
|
194
|
-
test_data.append((k, v))
|
|
195
|
-
|
|
196
|
-
assert test_data[0][0] == "inlet2"
|
|
197
|
-
assert test_data[0][1].path == r"setup/boundary-conditions/velocity-inlet/inlet2"
|
|
198
|
-
assert test_data[1][0] == "inlet1"
|
|
199
|
-
assert test_data[1][1].path == r"setup/boundary-conditions/velocity-inlet/inlet1"
|
|
200
|
-
|
|
201
|
-
test_data = []
|
|
202
|
-
for k, v in velocity_inlet["*let*"].items():
|
|
203
|
-
test_data.append((k, v))
|
|
204
|
-
|
|
205
|
-
assert test_data[0][0] == "inlet2"
|
|
206
|
-
assert test_data[0][1].path == r"setup/boundary-conditions/velocity-inlet/inlet2"
|
|
207
|
-
assert test_data[1][0] == "inlet1"
|
|
208
|
-
assert test_data[1][1].path == r"setup/boundary-conditions/velocity-inlet/inlet1"
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
@pytest.mark.fluent_version(">=23.1")
|
|
212
|
-
def test_api_upgrade(new_solver_session, capsys):
|
|
213
|
-
solver = new_solver_session
|
|
214
|
-
case_path = download_file("Static_Mixer_main.cas.h5", "pyfluent/static_mixer")
|
|
215
|
-
solver.tui.file.read_case(case_path)
|
|
216
|
-
timeout_loop(
|
|
217
|
-
lambda: "<solver_session>.settings.file.read_case" in capsys.readouterr().out,
|
|
218
|
-
timeout=5,
|
|
219
|
-
)
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
# Custom aliases are not tested with 25.1 or later due to conflicts with the actual aliases
|
|
223
|
-
# defined in the settings API
|
|
224
|
-
@pytest.mark.fluent_version("==24.2")
|
|
225
|
-
def test_deprecated_settings_with_custom_aliases(new_solver_session):
|
|
226
|
-
solver = new_solver_session
|
|
227
|
-
case_path = download_file("mixing_elbow.cas.h5", "pyfluent/mixing_elbow")
|
|
228
|
-
download_file("mixing_elbow.dat.h5", "pyfluent/mixing_elbow")
|
|
229
|
-
solver.file._setattr("_child_aliases", {"rcd": ("read_case_data", "rcd")})
|
|
230
|
-
with pytest.warns(DeprecatedSettingWarning):
|
|
231
|
-
solver.file.rcd(file_name=case_path)
|
|
232
|
-
|
|
233
|
-
solver.setup.boundary_conditions.velocity_inlet.child_object_type._child_aliases[
|
|
234
|
-
"mom"
|
|
235
|
-
] = ("momentum", "mom")
|
|
236
|
-
with pytest.warns(DeprecatedSettingWarning):
|
|
237
|
-
solver.setup.boundary_conditions.velocity_inlet["hot-inlet"].mom.velocity = 20
|
|
238
|
-
assert (
|
|
239
|
-
solver.setup.boundary_conditions.velocity_inlet[
|
|
240
|
-
"hot-inlet"
|
|
241
|
-
].momentum.velocity.value()
|
|
242
|
-
== 20
|
|
243
|
-
)
|
|
244
|
-
with pytest.warns(DeprecatedSettingWarning):
|
|
245
|
-
solver.setup.boundary_conditions.velocity_inlet["cold-inlet"].mom.velocity = 2
|
|
246
|
-
assert (
|
|
247
|
-
solver.setup.boundary_conditions.velocity_inlet[
|
|
248
|
-
"cold-inlet"
|
|
249
|
-
].momentum.velocity.value()
|
|
250
|
-
== 2
|
|
251
|
-
)
|
|
252
|
-
|
|
253
|
-
solver.setup.boundary_conditions.wall["wall-inlet"].thermal.thermal_bc = (
|
|
254
|
-
"Temperature"
|
|
255
|
-
)
|
|
256
|
-
assert (
|
|
257
|
-
len(
|
|
258
|
-
solver.setup.boundary_conditions.wall[
|
|
259
|
-
"wall-inlet"
|
|
260
|
-
].thermal.temperature._child_aliases
|
|
261
|
-
)
|
|
262
|
-
> 0
|
|
263
|
-
)
|
|
264
|
-
assert solver.setup.boundary_conditions.wall[
|
|
265
|
-
"wall-inlet"
|
|
266
|
-
].thermal.temperature._child_aliases["constant"] == ("value", "constant")
|
|
267
|
-
with pytest.warns(DeprecatedSettingWarning):
|
|
268
|
-
solver.setup.boundary_conditions.wall[
|
|
269
|
-
"wall-inlet"
|
|
270
|
-
].thermal.temperature.constant = 400
|
|
271
|
-
|
|
272
|
-
assert (
|
|
273
|
-
solver.setup.boundary_conditions.wall["wall-inlet"].thermal.temperature.value()
|
|
274
|
-
== 400
|
|
275
|
-
)
|
|
276
|
-
assert (
|
|
277
|
-
len(
|
|
278
|
-
solver.setup.boundary_conditions.wall[
|
|
279
|
-
"wall-inlet"
|
|
280
|
-
].thermal.temperature._child_aliases
|
|
281
|
-
)
|
|
282
|
-
> 0
|
|
283
|
-
)
|
|
284
|
-
assert isinstance(
|
|
285
|
-
solver.setup.boundary_conditions.wall[
|
|
286
|
-
"wall-inlet"
|
|
287
|
-
].thermal.temperature._child_alias_objs["constant"],
|
|
288
|
-
_Alias,
|
|
289
|
-
)
|
|
290
|
-
with pytest.warns(DeprecatedSettingWarning):
|
|
291
|
-
solver.setup.boundary_conditions.wall["wall-inlet"].thermal.t.value = 410
|
|
292
|
-
|
|
293
|
-
assert (
|
|
294
|
-
solver.setup.boundary_conditions.wall["wall-inlet"].thermal.temperature.value()
|
|
295
|
-
== 410
|
|
296
|
-
)
|
|
297
|
-
|
|
298
|
-
solver.setup.boundary_conditions._setattr("_child_aliases", {"w": ("wall", "w")})
|
|
299
|
-
with pytest.warns(DeprecatedSettingWarning):
|
|
300
|
-
solver.setup.boundary_conditions.w["wall-inlet"].thermal.temperature.value = 420
|
|
301
|
-
|
|
302
|
-
assert (
|
|
303
|
-
solver.setup.boundary_conditions.wall["wall-inlet"].thermal.temperature.value()
|
|
304
|
-
== 420
|
|
305
|
-
)
|
|
306
|
-
|
|
307
|
-
solver.setup._setattr("_child_aliases", {"bc": ("boundary_conditions", "bc")})
|
|
308
|
-
with pytest.warns(DeprecatedSettingWarning):
|
|
309
|
-
solver.setup.bc.wall["wall-inlet"].thermal.temperature.value = 430
|
|
310
|
-
|
|
311
|
-
assert (
|
|
312
|
-
solver.setup.boundary_conditions.wall["wall-inlet"].thermal.temperature.value()
|
|
313
|
-
== 430
|
|
314
|
-
)
|
|
315
|
-
|
|
316
|
-
with pytest.warns(DeprecatedSettingWarning):
|
|
317
|
-
solver.setup.boundary_conditions.wall[
|
|
318
|
-
"wall-inlet"
|
|
319
|
-
].thermal.temperature.constant = 400
|
|
320
|
-
|
|
321
|
-
assert (
|
|
322
|
-
solver.setup.boundary_conditions.wall["wall-inlet"].thermal.temperature.value()
|
|
323
|
-
== 400
|
|
324
|
-
)
|
|
325
|
-
|
|
326
|
-
solver.results._setattr("_child_aliases", {"gr": ("graphics", "gr")})
|
|
327
|
-
with pytest.warns(DeprecatedSettingWarning):
|
|
328
|
-
solver.results.gr.contour.create("c1")
|
|
329
|
-
|
|
330
|
-
with pytest.warns(DeprecatedSettingWarning):
|
|
331
|
-
solver.results.gr.contour["c1"].field = "pressure"
|
|
332
|
-
|
|
333
|
-
assert solver.results.graphics.contour["c1"].field() == "pressure"
|
|
334
|
-
|
|
335
|
-
with pytest.warns(DeprecatedSettingWarning):
|
|
336
|
-
del solver.results.gr.contour["c1"]
|
|
337
|
-
|
|
338
|
-
assert "c1" not in solver.results.graphics.contour
|
|
339
|
-
|
|
340
|
-
solver.setup.boundary_conditions.velocity_inlet[
|
|
341
|
-
"hot-inlet"
|
|
342
|
-
].momentum.velocity._child_aliases["hd"] = (
|
|
343
|
-
"../../turbulence/hydraulic_diameter",
|
|
344
|
-
"hd",
|
|
345
|
-
)
|
|
346
|
-
with pytest.warns(DeprecatedSettingWarning):
|
|
347
|
-
solver.setup.boundary_conditions.velocity_inlet[
|
|
348
|
-
"hot-inlet"
|
|
349
|
-
].momentum.velocity.hd = 10
|
|
350
|
-
assert (
|
|
351
|
-
solver.setup.boundary_conditions.velocity_inlet[
|
|
352
|
-
"hot-inlet"
|
|
353
|
-
].turbulence.hydraulic_diameter()
|
|
354
|
-
== 10
|
|
355
|
-
)
|
|
356
|
-
|
|
357
|
-
solver.setup.cell_zone_conditions.fluid["elbow-fluid"] = {"material": "air"}
|
|
358
|
-
|
|
359
|
-
solver.setup.boundary_conditions.wall["wall-inlet"] = {
|
|
360
|
-
"thermal": {"q_dot": {"value": 2000000000}, "wall_thickness": {"value": 0.002}}
|
|
361
|
-
}
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
@pytest.mark.fluent_version(">=25.1")
|
|
365
|
-
def test_deprecated_settings_with_settings_api_aliases(mixing_elbow_case_data_session):
|
|
366
|
-
solver = mixing_elbow_case_data_session
|
|
367
|
-
solver.settings.results.surfaces.iso_clip["clip-1"] = {}
|
|
368
|
-
assert solver.settings.results.surfaces.iso_clip["clip-1"].range() == {
|
|
369
|
-
"minimum": 0,
|
|
370
|
-
"maximum": 0,
|
|
371
|
-
}
|
|
372
|
-
solver.settings.results.surfaces.iso_clip["clip-1"] = {
|
|
373
|
-
"min": -0.0001,
|
|
374
|
-
"max": 0.0001,
|
|
375
|
-
}
|
|
376
|
-
assert solver.settings.results.surfaces.iso_clip["clip-1"].range() == {
|
|
377
|
-
"minimum": -0.0001,
|
|
378
|
-
"maximum": 0.0001,
|
|
379
|
-
}
|
|
380
|
-
solver.settings.results.graphics.contour["temperature"] = {}
|
|
381
|
-
solver.settings.results.graphics.contour["temperature"] = {
|
|
382
|
-
"field": "temperature",
|
|
383
|
-
"surfaces_list": "wall*",
|
|
384
|
-
"color_map": {
|
|
385
|
-
"visible": True,
|
|
386
|
-
"size": 100,
|
|
387
|
-
"color": "field-velocity",
|
|
388
|
-
"log_scale": False,
|
|
389
|
-
"format": "%0.1f",
|
|
390
|
-
"user_skip": 9,
|
|
391
|
-
"show_all": True,
|
|
392
|
-
"position": 1,
|
|
393
|
-
"font_name": "Helvetica",
|
|
394
|
-
"font_automatic": True,
|
|
395
|
-
"font_size": 0.032,
|
|
396
|
-
"length": 0.54,
|
|
397
|
-
"width": 6,
|
|
398
|
-
"bground_transparent": True,
|
|
399
|
-
"bground_color": "#CCD3E2",
|
|
400
|
-
"title_elements": "Variable and Object Name",
|
|
401
|
-
},
|
|
402
|
-
"range_option": {
|
|
403
|
-
"option": "auto-range-off",
|
|
404
|
-
"auto_range_off": {
|
|
405
|
-
"maximum": 400.0,
|
|
406
|
-
"minimum": 300,
|
|
407
|
-
"clip_to_range": False,
|
|
408
|
-
},
|
|
409
|
-
},
|
|
410
|
-
}
|
|
411
|
-
assert solver.settings.results.graphics.contour["temperature"].range_options() == {
|
|
412
|
-
"global_range": True,
|
|
413
|
-
"auto_range": False,
|
|
414
|
-
"clip_to_range": False,
|
|
415
|
-
"minimum": 300,
|
|
416
|
-
"maximum": 400.0,
|
|
417
|
-
}
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
@pytest.mark.fluent_version(">=23.1")
|
|
421
|
-
def test_command_return_type(new_solver_session):
|
|
422
|
-
solver = new_solver_session
|
|
423
|
-
version = solver.get_fluent_version()
|
|
424
|
-
case_path = download_file("mixing_elbow.cas.h5", "pyfluent/mixing_elbow")
|
|
425
|
-
download_file("mixing_elbow.dat.h5", "pyfluent/mixing_elbow")
|
|
426
|
-
ret = solver.file.read_case_data(file_name=case_path)
|
|
427
|
-
assert ret is None if version >= FluentVersion.v242 else not None
|
|
428
|
-
solver.solution.report_definitions.surface["surface-1"] = dict(
|
|
429
|
-
surface_names=["cold-inlet"]
|
|
430
|
-
)
|
|
431
|
-
ret = solver.solution.report_definitions.compute(report_defs=["surface-1"])
|
|
432
|
-
assert ret is not None
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
@pytest.fixture
|
|
436
|
-
def warning_record():
|
|
437
|
-
wrec = WarningsRecorder(_ispytest=True)
|
|
438
|
-
with wrec:
|
|
439
|
-
warnings.simplefilter("ignore", ResourceWarning)
|
|
440
|
-
yield wrec
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
@pytest.mark.skip("https://github.com/ansys/pyfluent/issues/2712")
|
|
444
|
-
@pytest.mark.fluent_version(">=24.2")
|
|
445
|
-
def test_unstable_settings_warning(new_solver_session, warning_record):
|
|
446
|
-
solver = new_solver_session
|
|
447
|
-
solver.file.export
|
|
448
|
-
assert len(warning_record) == 1
|
|
449
|
-
assert warning_record.pop().category == UnstableSettingWarning
|
|
450
|
-
try:
|
|
451
|
-
solver.file.exp
|
|
452
|
-
except AttributeError:
|
|
453
|
-
pass
|
|
454
|
-
assert len(warning_record) == 0
|
|
455
|
-
solver.file.export
|
|
456
|
-
assert len(warning_record) == 1
|
|
457
|
-
assert warning_record.pop().category == UnstableSettingWarning
|
|
458
|
-
|
|
459
|
-
# Issue in running in CI (probably due to -gu mode)
|
|
460
|
-
# case_path = download_file("mixing_elbow.cas.h5", "pyfluent/mixing_elbow")
|
|
461
|
-
# solver.file.read_case_data(file_name=case_path)
|
|
462
|
-
# img_path = "a.png"
|
|
463
|
-
# Path(img_path).unlink(missing_ok=True)
|
|
464
|
-
# solver.results.graphics.picture.save_picture(file_name=img_path)
|
|
465
|
-
# assert len(recwarn) == 0
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
@pytest.mark.fluent_version(">=24.2")
|
|
469
|
-
def test_generated_code_special_cases(new_solver_session):
|
|
470
|
-
solver = new_solver_session
|
|
471
|
-
icing_cls = solver.setup.boundary_conditions._child_classes[
|
|
472
|
-
"velocity_inlet"
|
|
473
|
-
].child_object_type._child_classes["icing"]
|
|
474
|
-
fensapice_drop_vrh_cls = icing_cls._child_classes["fensapice_drop_vrh"]
|
|
475
|
-
fensapice_drop_vrh_1_cls = icing_cls._child_classes["fensapice_drop_vrh_1"]
|
|
476
|
-
assert fensapice_drop_vrh_cls.fluent_name != fensapice_drop_vrh_1_cls.fluent_name
|
|
477
|
-
assert to_python_name(fensapice_drop_vrh_cls.fluent_name) == to_python_name(
|
|
478
|
-
fensapice_drop_vrh_1_cls.fluent_name
|
|
479
|
-
)
|
|
480
|
-
assert fensapice_drop_vrh_cls.__name__ != fensapice_drop_vrh_1_cls.__name__
|
|
481
|
-
|
|
482
|
-
assert (
|
|
483
|
-
solver.file.read_case.file_name.fluent_name
|
|
484
|
-
== solver.file.write_case.file_name.fluent_name
|
|
485
|
-
)
|
|
486
|
-
assert (
|
|
487
|
-
solver.file.read_case.file_name.__class__.__name__
|
|
488
|
-
!= solver.file.write_case.file_name.__class__.__name__
|
|
489
|
-
)
|
|
490
|
-
read_file_bases = solver.file.read_case.file_name.__class__.__bases__
|
|
491
|
-
assert _InputFile in read_file_bases
|
|
492
|
-
assert _OutputFile not in read_file_bases
|
|
493
|
-
write_file_bases = solver.file.write_case.file_name.__class__.__bases__
|
|
494
|
-
assert _InputFile not in write_file_bases
|
|
495
|
-
assert _OutputFile in write_file_bases
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
@pytest.mark.skip("https://github.com/ansys/pyfluent/issues/3591")
|
|
499
|
-
@pytest.mark.fluent_version(">=25.1")
|
|
500
|
-
def test_child_alias_with_parent_path(mixing_elbow_settings_session):
|
|
501
|
-
solver = mixing_elbow_settings_session
|
|
502
|
-
|
|
503
|
-
# Following set_state should not throw InactiveObjectError
|
|
504
|
-
solver.settings.setup.materials.fluid["air"] = {
|
|
505
|
-
"density": {"option": "ideal-gas"},
|
|
506
|
-
"specific_heat": {"value": 1006.43, "option": "constant"},
|
|
507
|
-
"thermal_conductivity": {"value": 0.0242, "option": "constant"},
|
|
508
|
-
"molecular_weight": {"value": 28.966, "option": "constant"},
|
|
509
|
-
}
|
|
510
|
-
assert solver.settings.setup.materials.fluid["air"].density.option() == "ideal-gas"
|
|
511
|
-
assert solver.settings.setup.materials.fluid["air"].specific_heat.value() == 1006.43
|
|
512
|
-
assert (
|
|
513
|
-
solver.settings.setup.materials.fluid["air"].thermal_conductivity.value()
|
|
514
|
-
== 0.0242
|
|
515
|
-
)
|
|
516
|
-
assert (
|
|
517
|
-
solver.settings.setup.materials.fluid["air"].molecular_weight.value() == 28.966
|
|
518
|
-
)
|
|
519
|
-
|
|
520
|
-
solver.settings.solution.initialization.hybrid_initialize()
|
|
521
|
-
assert (
|
|
522
|
-
solver.settings.setup.models.discrete_phase.numerics.node_based_averaging.kernel._child_aliases
|
|
523
|
-
== {
|
|
524
|
-
"gaussian_factor": ("../gaussian_factor", "gaussian-factor"),
|
|
525
|
-
"option": ("../kernel_type", "option"),
|
|
526
|
-
}
|
|
527
|
-
)
|
|
528
|
-
solver.settings.setup.models.discrete_phase.numerics.node_based_averaging.enabled = (
|
|
529
|
-
True
|
|
530
|
-
)
|
|
531
|
-
solver.settings.setup.models.discrete_phase.numerics.node_based_averaging.kernel_type = (
|
|
532
|
-
"inverse-distance"
|
|
533
|
-
)
|
|
534
|
-
solver.settings.setup.models.discrete_phase.numerics.node_based_averaging.kernel = {
|
|
535
|
-
"option": "gaussian",
|
|
536
|
-
"gaussian_factor": 0.5,
|
|
537
|
-
}
|
|
538
|
-
assert (
|
|
539
|
-
solver.settings.setup.models.discrete_phase.numerics.node_based_averaging.kernel_type()
|
|
540
|
-
== "gaussian"
|
|
541
|
-
)
|
|
542
|
-
assert (
|
|
543
|
-
solver.settings.setup.models.discrete_phase.numerics.node_based_averaging.gaussian_factor()
|
|
544
|
-
== 0.5
|
|
545
|
-
)
|
|
546
|
-
solver.settings.setup.models.discrete_phase.numerics.node_based_averaging.kernel.gaussian_factor = (
|
|
547
|
-
0.6
|
|
548
|
-
)
|
|
549
|
-
assert (
|
|
550
|
-
solver.settings.setup.models.discrete_phase.numerics.node_based_averaging.gaussian_factor()
|
|
551
|
-
== 0.6
|
|
552
|
-
)
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
@pytest.mark.fluent_version(">=25.1")
|
|
556
|
-
def test_commands_not_in_settings(new_solver_session):
|
|
557
|
-
solver = new_solver_session
|
|
558
|
-
|
|
559
|
-
for command in ["exit", "switch_to_meshing_mode"]:
|
|
560
|
-
assert command not in dir(solver.settings)
|
|
561
|
-
with pytest.raises(AttributeError):
|
|
562
|
-
getattr(solver.settings, command)
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
@pytest.mark.fluent_version(">=25.1")
|
|
566
|
-
def test_deprecated_command_arguments(mixing_elbow_case_data_session):
|
|
567
|
-
solver = mixing_elbow_case_data_session
|
|
568
|
-
with pytest.warns() as record:
|
|
569
|
-
# all_boundary_zones is an unknown/unsupported keyword
|
|
570
|
-
solver.settings.results.report.fluxes.mass_flow(
|
|
571
|
-
all_boundary_zones=False, zones=["cold-inlet", "hot-inlet", "outlet"]
|
|
572
|
-
)
|
|
573
|
-
assert len(record) == 1
|
|
574
|
-
assert record[0].category == PyFluentUserWarning
|
|
575
|
-
assert "all_boundary_zones" in str(record[0].message)
|
|
576
|
-
|
|
577
|
-
solver.settings.results.graphics.mesh.create("m1")
|
|
578
|
-
solver.settings.results.graphics.mesh.make_a_copy(from_="m1", to="m2")
|
|
579
|
-
solver.settings.results.graphics.mesh.copy(
|
|
580
|
-
from_name="m1", new_name="m3"
|
|
581
|
-
) # deprecated
|
|
582
|
-
assert set(solver.settings.results.graphics.mesh.get_object_names()) == {
|
|
583
|
-
"m1",
|
|
584
|
-
"m2",
|
|
585
|
-
"m3",
|
|
586
|
-
}
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
@pytest.mark.fluent_version(">=25.2")
|
|
590
|
-
def test_return_types_of_operations_on_named_objects(mixing_elbow_settings_session):
|
|
591
|
-
solver = mixing_elbow_settings_session
|
|
592
|
-
|
|
593
|
-
var1 = solver.settings.setup.materials.fluid.create("air-created")
|
|
594
|
-
assert var1 == solver.settings.setup.materials.fluid["air-created"]
|
|
595
|
-
assert var1.obj_name == "air-created"
|
|
596
|
-
|
|
597
|
-
var2 = solver.settings.setup.materials.fluid.rename(
|
|
598
|
-
old="air-created", new="air-renamed"
|
|
599
|
-
)
|
|
600
|
-
assert var2 is None
|
|
601
|
-
|
|
602
|
-
var3 = solver.settings.setup.materials.fluid.make_a_copy(
|
|
603
|
-
from_="air-renamed", to="air-copied"
|
|
604
|
-
)
|
|
605
|
-
assert var3 == solver.settings.setup.materials.fluid["air-copied"]
|
|
606
|
-
assert var3.obj_name == "air-copied"
|
|
@@ -1,85 +0,0 @@
|
|
|
1
|
-
import pytest
|
|
2
|
-
|
|
3
|
-
from ansys.fluent.core import examples
|
|
4
|
-
from ansys.fluent.core.filereader.case_file import SettingsFile as SettingsReader
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
def call_settings_reader(
|
|
8
|
-
settings_file_name: str | None = None, expected: dict | None = None
|
|
9
|
-
):
|
|
10
|
-
reader = SettingsReader(settings_file_name=settings_file_name)
|
|
11
|
-
if expected is not None:
|
|
12
|
-
assert reader.precision() == expected["precision"]
|
|
13
|
-
assert reader.num_dimensions() == expected["num_dimensions"]
|
|
14
|
-
assert reader.iter_count() == expected["iter_count"]
|
|
15
|
-
assert {
|
|
16
|
-
p.name: (p.numeric_value, p.units) for p in reader.input_parameters()
|
|
17
|
-
} == expected["input_parameters"]
|
|
18
|
-
assert {p.name: p.units for p in reader.output_parameters()} == expected[
|
|
19
|
-
"output_parameters"
|
|
20
|
-
]
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
def call_settings_reader_static_mixer(
|
|
24
|
-
settings_file_name: str | None = None,
|
|
25
|
-
):
|
|
26
|
-
call_settings_reader(
|
|
27
|
-
settings_file_name=settings_file_name,
|
|
28
|
-
expected=dict(
|
|
29
|
-
precision=2,
|
|
30
|
-
num_dimensions=3,
|
|
31
|
-
iter_count=100,
|
|
32
|
-
input_parameters=dict(
|
|
33
|
-
inlet1_temp=(300, "K"),
|
|
34
|
-
inlet1_vel=(1, "m/s"),
|
|
35
|
-
inlet2_temp=(350, "K"),
|
|
36
|
-
inlet2_vel=(1, "m/s"),
|
|
37
|
-
),
|
|
38
|
-
output_parameters={
|
|
39
|
-
"outlet-temp-avg-op": "K",
|
|
40
|
-
"outlet-vel-avg-op": "m s^-1",
|
|
41
|
-
},
|
|
42
|
-
),
|
|
43
|
-
)
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
def static_mixer_settings_file():
|
|
47
|
-
return examples.download_file(
|
|
48
|
-
"Static_Mixer_Params",
|
|
49
|
-
"pyfluent/static_mixer",
|
|
50
|
-
return_without_path=False,
|
|
51
|
-
)
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
def test_settings_reader_static_mixer_h5():
|
|
55
|
-
call_settings_reader_static_mixer(settings_file_name=static_mixer_settings_file())
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
def test_meshing_unavailable():
|
|
59
|
-
reader = SettingsReader(settings_file_name=static_mixer_settings_file())
|
|
60
|
-
with pytest.raises(AttributeError):
|
|
61
|
-
reader.get_mesh()
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
def test_settings_reader_get_rp_and_config_vars():
|
|
65
|
-
reader = SettingsReader(settings_file_name=static_mixer_settings_file())
|
|
66
|
-
rp_vars = reader.rp_vars()
|
|
67
|
-
assert rp_vars
|
|
68
|
-
assert hasattr(rp_vars, "__getitem__")
|
|
69
|
-
config_vars = reader.config_vars()
|
|
70
|
-
assert config_vars
|
|
71
|
-
assert hasattr(config_vars, "__getitem__")
|
|
72
|
-
assert config_vars["rp-3d?"] is True
|
|
73
|
-
assert reader.config_var("rp-3d?") is True
|
|
74
|
-
assert reader.config_var.rp_3d__q() is True
|
|
75
|
-
assert len(reader.rp_var.context.map_r17__plus()) == 53
|
|
76
|
-
|
|
77
|
-
with pytest.raises(RuntimeError) as msg:
|
|
78
|
-
reader.rp_var.defaults.pre_r19__dot0_early()
|
|
79
|
-
|
|
80
|
-
with pytest.raises(ValueError) as msg:
|
|
81
|
-
reader.config_var("rp-3d")
|
|
82
|
-
assert (
|
|
83
|
-
msg.value.args[0] == "'config-vars' has no attribute 'rp-3d'.\n"
|
|
84
|
-
"The most similar names are: rp-3d?, rp-des?."
|
|
85
|
-
)
|