Skip to content

Commit

Permalink
fix export_field_file on grid (#4308)
Browse files Browse the repository at this point in the history
Co-authored-by: Maxime Rey <87315832+MaxJPRey@users.noreply.github.com>
  • Loading branch information
gmalinve and MaxJPRey committed Mar 4, 2024
1 parent bfa64a5 commit b299218
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 28 deletions.
6 changes: 3 additions & 3 deletions _unittest/test_12_1_PostProcessing.py
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ def test_07_export_fields_from_Calculator(self):
self.aedtapp.post.export_field_file_on_grid(
"E",
"Setup1 : LastAdaptive",
self.aedtapp.available_variations.nominal_w_values,
self.aedtapp.available_variations.nominal_w_values_dict,
os.path.join(self.local_scratch.path, "Efield.fld"),
grid_stop=[5, 5, 5],
grid_step=[0.5, 0.5, 0.5],
Expand All @@ -233,7 +233,7 @@ def test_07_export_fields_from_Calculator(self):
self.aedtapp.post.export_field_file_on_grid(
"Mag_E",
"Setup1 : LastAdaptive",
self.aedtapp.available_variations.nominal_w_values,
self.aedtapp.available_variations.nominal_w_values_dict,
os.path.join(self.local_scratch.path, "MagEfieldSph.fld"),
gridtype="Spherical",
grid_stop=[5, 300, 300],
Expand All @@ -246,7 +246,7 @@ def test_07_export_fields_from_Calculator(self):
self.aedtapp.post.export_field_file_on_grid(
"Mag_E",
"Setup1 : LastAdaptive",
self.aedtapp.available_variations.nominal_w_values,
self.aedtapp.available_variations.nominal_w_values_dict,
os.path.join(self.local_scratch.path, "MagEfieldCyl.fld"),
gridtype="Cylindrical",
grid_stop=[5, 300, 5],
Expand Down
13 changes: 6 additions & 7 deletions _unittest/test_12_PostProcessing.py
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,7 @@ def test_17_circuit(self, circuit_test):
assert len(data2.data_magnitude()) > 0
context = {"algorithm": "FFT", "max_frequency": "100MHz", "time_stop": "200ns", "test": ""}
data3 = circuit_test.post.get_solution_data(["V(net_11)"], "Transient", "Spectral", context=context)
assert data3.units_sweeps["Spectrum"] == "GHz"
assert data3.units_sweeps["Spectrum"] == circuit_test.odesktop.GetDefaultUnit("Frequency")
assert len(data3.data_real()) > 0
new_report = circuit_test.post.reports_by_category.spectral(["dB(V(net_11))"], "Transient")
new_report.window = "Hanning"
Expand Down Expand Up @@ -320,7 +320,6 @@ def test_17_circuit(self, circuit_test):
new_report.time_stop = "190ns"
new_report.plot_continous_spectrum = True
assert new_report.create()
pass

@pytest.mark.skipif(is_linux, reason="Crashing on Linux")
def test_18_diff_plot(self, diff_test):
Expand Down Expand Up @@ -898,7 +897,7 @@ def test_76_ipk_get_scalar_field_value(self, icepak_post):
"Heat_Flow_Rate",
scalar_function="Integrate",
solution=None,
variation_dict=["power_block:=", ["0.25W"], "power_source:=", ["0.075W"]],
variation_dict={"power_block": "0.25W", "power_source": "0.075W"},
isvector=False,
intrinsics=None,
phase=None,
Expand All @@ -910,7 +909,7 @@ def test_76_ipk_get_scalar_field_value(self, icepak_post):
"Heat_Flow_Rate",
scalar_function="Integrate",
solution=None,
variation_dict=["power_block:=", ["0.6W"], "power_source:=", ["0.15W"]],
variation_dict={"power_block": "0.6W", "power_source": "0.15W"},
isvector=False,
intrinsics=None,
phase=None,
Expand All @@ -922,7 +921,7 @@ def test_76_ipk_get_scalar_field_value(self, icepak_post):
"Heat_Flow_Rate",
scalar_function="Integrate",
solution=None,
variation_dict=["power_block:=", ["0.6W"], "power_source:=", ["0.15W"]],
variation_dict={"power_block": "0.6W", "power_source": "0.15W"},
isvector=False,
intrinsics=None,
phase=None,
Expand All @@ -934,7 +933,7 @@ def test_76_ipk_get_scalar_field_value(self, icepak_post):
"Temperature",
scalar_function="Maximum",
solution=None,
variation_dict=["power_block:=", ["0.6W"], "power_source:=", ["0.15W"]],
variation_dict={"power_block": "0.6W", "power_source": "0.15W"},
isvector=False,
intrinsics=None,
phase=None,
Expand All @@ -946,7 +945,7 @@ def test_76_ipk_get_scalar_field_value(self, icepak_post):
"Temperature",
scalar_function="Maximum",
solution=None,
variation_dict=["power_block:=", ["0.6W"], "power_source:=", ["0.15W"]],
variation_dict={"power_block": "0.6W", "power_source": "0.15W"},
isvector=False,
intrinsics=None,
phase=None,
Expand Down
50 changes: 32 additions & 18 deletions pyaedt/modules/PostProcessor.py
Original file line number Diff line number Diff line change
Expand Up @@ -2456,23 +2456,30 @@ def get_scalar_field_value(
elif object_type == "point":
self.ofieldsreporter.EnterPoint(obj_list)
self.ofieldsreporter.CalcOp(scalar_function)

if not variation_dict:
variation_dict = self._app.available_variations.nominal_w_values
variation_dict = self._app.available_variations.nominal_w_values_dict

variation = []
for el, value in variation_dict.items():
variation.append(el + ":=")
variation.append(value)

if intrinsics:
if "Transient" in solution:
variation_dict.append("Time:=")
variation_dict.append(intrinsics)
variation.append("Time:=")
variation.append(intrinsics)
else:
variation_dict.append("Freq:=")
variation_dict.append(intrinsics)
variation_dict.append("Phase:=")
variation.append("Freq:=")
variation.append(intrinsics)
variation.append("Phase:=")
if phase:
variation_dict.append(phase)
variation.append(phase)
else:
variation_dict.append("0deg")
variation.append("0deg")

file_name = os.path.join(self._app.working_directory, generate_unique_name("temp_fld") + ".fld")
self.ofieldsreporter.CalculatorWrite(file_name, ["Solution:=", solution], variation_dict)
self.ofieldsreporter.CalculatorWrite(file_name, ["Solution:=", solution], variation)
value = None
if os.path.exists(file_name) or settings.remote_rpc_session:
with open_file(file_name, "r") as f:
Expand Down Expand Up @@ -2600,28 +2607,35 @@ def export_field_file_on_grid(
else:
self.logger.error("Error in the type of the grid.")
return False

if not variation_dict:
variation_dict = self._app.available_variations.nominal_w_values
variation_dict = self._app.available_variations.nominal_w_values_dict

variation = []
for el, value in variation_dict.items():
variation.append(el + ":=")
variation.append(value)

if intrinsics:
if "Transient" in solution:
variation_dict.append("Time:=")
variation_dict.append(intrinsics)
variation.append("Time:=")
variation.append(intrinsics)
else:
variation_dict.append("Freq:=")
variation_dict.append(intrinsics)
variation_dict.append("Phase:=")
variation.append("Freq:=")
variation.append(intrinsics)
variation.append("Phase:=")
if phase:
variation_dict.append(phase)
variation.append(phase)
else:
variation_dict.append("0deg")
variation.append("0deg")

self.ofieldsreporter.ExportOnGrid(
filename,
grid_start_wu,
grid_stop_wu,
grid_step_wu,
solution,
variation_dict,
variation,
True,
gridtype,
grid_center,
Expand Down

0 comments on commit b299218

Please sign in to comment.