Skip to content

Improved 3dcomponent creation #1044

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 8 commits into from
Apr 15, 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
1 change: 1 addition & 0 deletions _unittest/test_09_VariableManager.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ def test_02_test_formula(self):
self.aedtapp["Var1"] = 3
self.aedtapp["Var2"] = "12deg"
self.aedtapp["Var3"] = "Var1 * Var2"

self.aedtapp["$PrjVar1"] = "2*pi"
self.aedtapp["$PrjVar2"] = 45
self.aedtapp["$PrjVar3"] = "sqrt(34 * $PrjVar2/$PrjVar1 )"
Expand Down
2 changes: 2 additions & 0 deletions _unittest/test_27_Maxwell2D.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,8 @@ def test_16_enable_inductance_computation(self):
def test_17_mesh_settings(self):
assert self.aedtapp.mesh.initial_mesh_settings
assert self.aedtapp.mesh.initial_mesh_settings.props
assert self.aedtapp.change_design_settings({"Multiplier": 2})
assert self.aedtapp.change_symmetry_multiplier(1)

def test_18_end_connection(self):
self.aedtapp.insert_design("EndConnection")
Expand Down
26 changes: 22 additions & 4 deletions pyaedt/application/Design.py
Original file line number Diff line number Diff line change
Expand Up @@ -2336,6 +2336,26 @@ def dataset_exists(self, name, is_project_dataset=True):
self.logger.info("Dataset %s doesn't exist.", name)
return False

@pyaedt_function_handler()
def change_design_settings(self, settings):
"""Set Design Settings.

Parameters
----------
settings : dict
Dictionary of settings with value to apply.

Returns
-------
bool
"""
arg = ["NAME:Design Settings Data"]
for k, v in settings.items():
arg.append(k + ":=")
arg.append(v)
self.odesign.SetDesignSettings(arg)
return True

@pyaedt_function_handler()
def change_automatically_use_causal_materials(self, lossy_dielectric=True):
"""Enable or disable the automatic use of causal materials for lossy dielectrics.
Expand All @@ -2360,8 +2380,7 @@ def change_automatically_use_causal_materials(self, lossy_dielectric=True):
self.logger.info("Enabling Automatic use of causal materials")
else:
self.logger.info("Disabling Automatic use of causal materials")
self.odesign.SetDesignSettings(["NAME:Design Settings Data", "Calculate Lossy Dielectrics:=", lossy_dielectric])
return True
return self.change_design_settings({"Calculate Lossy Dielectrics": lossy_dielectric})

@pyaedt_function_handler()
def change_material_override(self, material_override=True):
Expand All @@ -2387,8 +2406,7 @@ def change_material_override(self, material_override=True):
self.logger.info("Enabling Material Override")
else:
self.logger.info("Disabling Material Override")
self.odesign.SetDesignSettings(["NAME:Design Settings Data", "Allow Material Override:=", material_override])
return True
return self.change_design_settings({"Allow Material Override": material_override})

@pyaedt_function_handler()
def change_validation_settings(
Expand Down
3 changes: 3 additions & 0 deletions pyaedt/application/Variables.py
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,9 @@ def decompose_variable_value(variable_value, full_variables={}):
if loc:
loc_units = loc.span()[0]
extract_units = variable_value[loc_units:]
chars = set("+*/()[]")
if any((c in chars) for c in extract_units):
return variable_value, units
try:
float_value = float(variable_value[0:loc_units])
units = extract_units
Expand Down
35 changes: 18 additions & 17 deletions pyaedt/maxwell.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,21 @@ def design_file(self):
design_file = os.path.join(self.working_directory, "design_data.json")
return design_file

@pyaedt_function_handler()
def change_symmetry_multiplier(self, value=1):
"""Set the Design Symmetry Multiplier to the selected value.

Parameters
----------
value : int, optional
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
value : int, optional
value : int, optional
Value used as the Design Symmetry Multiplier coefficient. The default value is ``1``.

Value used as the Design Symmetry Multiplier coefficient. The default value is ``1``.

Returns
-------
bool
"""
return self.change_design_settings({"Multiplier": value})

@pyaedt_function_handler()
def change_inductance_computation(self, compute_transient_inductance=True, incremental_matrix=False):
"""Enable the inductance computation for the transient analysis and set the incremental matrix.
Expand All @@ -100,16 +115,9 @@ def change_inductance_computation(self, compute_transient_inductance=True, incre

>>> oDesign.SetDesignSettings
"""
self.odesign.SetDesignSettings(
[
"NAME:Design Settings Data",
"ComputeTransientInductance:=",
compute_transient_inductance,
"ComputeIncrementalMatrix:=",
incremental_matrix,
]
return self.change_design_settings(
{"ComputeTransientInductance": compute_transient_inductance, "ComputeIncrementalMatrix": incremental_matrix}
)
return True

@pyaedt_function_handler()
def set_core_losses(self, objects, value=True):
Expand Down Expand Up @@ -1232,14 +1240,7 @@ def model_depth(self):
@model_depth.setter
def model_depth(self, value):
"""Set model depth."""

self.odesign.SetDesignSettings(
[
"NAME:Design Settings Data",
"ModelDepth:=",
value,
]
)
return self.chaange_design_settings({"ModelDepth": value})

@pyaedt_function_handler()
def generate_design_data(self, linefilter=None, objectfilter=None):
Expand Down
14 changes: 9 additions & 5 deletions pyaedt/modeler/Model3D.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,16 +157,19 @@ def create_3dcomponent(
allcs = self.oeditor.GetCoordinateSystems()
arg.append("IncludedCS:="), arg.append(allcs)
arg.append("ReferenceCS:="), arg.append(activecs)
variables = variables_to_include
arg.append("IncludedParameters:="), arg.append(variables)
variables = self._app._variable_manager.dependent_variable_names
par_description = []
if variables_to_include:
variables = variables_to_include
else:
variables = self._app._variable_manager.independent_variable_names
for el in variables:
par_description.append(el)
par_description.append(el + ":=")
par_description.append("")
arg.append("IncludedParameters:="), arg.append(variables)
variables = self._app._variable_manager.dependent_variable_names
arg.append("IncludedDependentParameters:="), arg.append(variables)
for el in variables:
par_description.append(el)
par_description.append(el + ":=")
par_description.append("")
arg.append("ParameterDescription:="), arg.append(par_description)
arg.append("IsLicensed:="), arg.append(False)
Expand Down Expand Up @@ -195,6 +198,7 @@ def create_3dcomponent(
exc = self._app.get_oo_name(self._app.odesign, "Excitations")
if exc and exc[0] not in self._app.excitations:
excitations.extend(exc)
excitations = list(set([i.split(":")[0] for i in excitations]))
arg2.append("Excitations:="), arg2.append(excitations)
meshops = [el.name for el in self._app.mesh.meshoperations]
arg2.append("MeshOperations:="), arg2.append(meshops)
Expand Down