Skip to content

Refactored DesignXPloration.py classes to support vaiables customization #1003

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Mar 28, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion _unittest/test_20_HFSS.py
Original file line number Diff line number Diff line change
Expand Up @@ -568,7 +568,7 @@ def test_24_create_curvilinear(self):
def test_25_create_parametrics(self):
self.aedtapp["w1"] = "10mm"
self.aedtapp["w2"] = "2mm"
setup1 = self.aedtapp.parametrics.add({"w1": "LIN 0.1mm 20mm 0.2mm"})
setup1 = self.aedtapp.parametrics.add("w1", 0.1, 20, 0.2, "LinearStep")
assert setup1
assert setup1.add_variation("w2", "0.1mm", 10, 11)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I understand the logic, but what I find confusing is having 3 methods to do the same thing. parametrics.add, parametrics.set_variation, optimization.add_variable.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks. I've renamed set_variable to add_variation to keep consistency between optimizations object and parametrics object

assert setup1.add_calculation(
Expand Down Expand Up @@ -619,27 +619,33 @@ def test_26_create_optimization(self):

def test_27_create_doe(self):
setup2 = self.aedtapp.optimizations.add("db(S(1,1))", ranges={"Freq": "2.5GHz"}, optim_type="DXDOE")
assert setup2.add_variation("w1", 0.1, 10, 51)
assert setup2
assert setup2.add_goal(calculation="dB(S(1,1))", ranges={"Freq": "2.6GHz"})
assert setup2.add_calculation(calculation="dB(S(1,1))", ranges={"Freq": "2.5GHz"})

def test_28A_create_dx(self):
setup2 = self.aedtapp.optimizations.add(None, {"w1": "1mm", "w2": "2mm"}, optim_type="optiSLang")
assert setup2.add_variation("w1", 0.1, 10, 51)
assert not setup2.add_variation("w3", 0.1, 10, 51)
assert setup2
assert setup2.add_goal(calculation="dB(S(1,1))", ranges={"Freq": "2.6GHz"})

def test_28B_create_dx(self):
setup2 = self.aedtapp.optimizations.add(None, {"w1": "1mm", "w2": "2mm"}, optim_type="DesignExplorer")
assert setup2.add_variation("w1", 0.1, 10, 51)
assert setup2
assert setup2.add_goal(calculation="dB(S(1,1))", ranges={"Freq": "2.6GHz"})

def test_29_create_sensitivity(self):
setup2 = self.aedtapp.optimizations.add("db(S(1,1))", ranges={"Freq": "2.5GHz"}, optim_type="Sensitivity")
assert setup2.add_variation("w1", 0.1, 10, 51)
assert setup2
assert setup2.add_calculation(calculation="dB(S(1,1))", ranges={"Freq": "2.6GHz"})

def test_29_create_statistical(self):
setup2 = self.aedtapp.optimizations.add("db(S(1,1))", ranges={"Freq": "2.5GHz"}, optim_type="Statistical")
assert setup2.add_variation("w1", 0.1, 10, 0.1, "LinearStep")
assert setup2
assert setup2.add_calculation(calculation="dB(S(1,1))", ranges={"Freq": "2.6GHz"})

Expand Down
4 changes: 3 additions & 1 deletion examples/01-Modeling-Setup/Optimetrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# This example creates a simple parametrics analysis with output calculations.

sweep = hfss.parametrics.add({"w2": "LIN 90mm 200mm 5mm"})
sweep = hfss.parametrics.add("w2", 90, 200, 5)
sweep.add_variation("w1", 0.1, 2, 10)
sweep.add_calculation(calculation="dB(S(1,1))", ranges={"Freq": "2.5GHz"})
sweep.add_calculation(calculation="dB(S(1,1))", ranges={"Freq": "2.6GHz"})
Expand All @@ -75,6 +75,7 @@
# This example creates a sensitivity analysis with output calculations.

sweep2 = hfss.optimizations.add(calculation="dB(S(1,1))", ranges={"Freq": "2.5GHz"}, optim_type="Sensitivity")
sweep2.add_variation("w1", 0.1, 3, 0.5)
sweep2.add_calculation(calculation="dB(S(1,1))", ranges={"Freq": "2.6GHz"})

###############################################################################
Expand All @@ -85,6 +86,7 @@
# This example creates an optimization based on goals and calculations.

sweep3 = hfss.optimizations.add(calculation="dB(S(1,1))", ranges={"Freq": "2.5GHz"})

sweep3.add_goal(calculation="dB(S(1,1))", ranges={"Freq": "2.6GHz"})
sweep3.add_goal(calculation="dB(S(1,1))", ranges={"Freq": ("2.6GHz", "5GHz")})
sweep3.add_goal(
Expand Down
2 changes: 1 addition & 1 deletion examples/02-Maxwell/Maxwell3DTeam3.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@
################################################################################
# Add a linear parametric sweep for the two coil positions
sweepname = "CoilSweep"
param = M3D.parametrics.add({"Coil_Position": "LIN -20mm 0mm 20mm"}, parametricname=sweepname)
param = M3D.parametrics.add("Coil_Position", -20, 0, 20, "LinearStep", parametricname=sweepname)
param.props["ProdOptiSetupDataV2"]["SaveFields"] = True
param.props["ProdOptiSetupDataV2"]["CopyMesh"] = False
param.props["ProdOptiSetupDataV2"]["SolveWithCopiedMeshOnly"] = True
Expand Down
4 changes: 3 additions & 1 deletion pyaedt/hfss.py
Original file line number Diff line number Diff line change
Expand Up @@ -4282,7 +4282,9 @@ def _create_sbr_doppler_sweep(self, setupname, time_var, tstart, tstop, tsweep,
time_sweep = self.modeler._arg_with_dim(tsweep, "s")
time_stop = self.modeler._arg_with_dim(tstop, "s")
sweep_range = "LIN {} {} {}".format(time_start, time_stop, time_sweep)
return self.parametrics.add({time_var: sweep_range}, setupname, parametricname=parametric_name)
return self.parametrics.add(
time_var, tstart, time_stop, tsweep, "LinearStep", setupname, parametricname=parametric_name
)

@pyaedt_function_handler()
def create_sbr_chirp_i_doppler_setup(
Expand Down
Loading