Skip to content
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

Add ..Update multiple variables simultaneously #5515

Open
Dr-Hawal-R opened this issue Dec 2, 2024 · 0 comments
Open

Add ..Update multiple variables simultaneously #5515

Dr-Hawal-R opened this issue Dec 2, 2024 · 0 comments
Labels
enhancement New features or code improvements

Comments

@Dr-Hawal-R
Copy link
Contributor

Description of the feature

Suppose a project has many variables, such as a DOE. In that case, exporting the geometry for each variation of the DOE becomes slow using the current method of applying one variable at a time using a for loop.

Steps for implementing the feature

def set_multiple_variables(design_variables, project_variables=None):
"""
Updates design and project variables in the HFSS (High Frequency Structure Simulator) application.

   Parameters:
   -----------
   design_variables : dict
       A dictionary where keys are the names of design variables, and values are their respective values.
       Example: {"Width": "5mm", "Height": "10mm"}

   project_variables : dict, optional
       A dictionary where keys are the names of project variables, and values are their respective values.
       If not provided, only the design variables are updated.

   Returns:
   --------
   None
       The method modifies the variables directly in the HFSS application via the `ChangeProperty` method.

   Notes:
   ------
   - The method updates the "LocalVariables" tab for design variables.
   - If `project_variables` is provided, it updates the "ProjectVariables" tab as well.
   - This function assumes the presence of a global `hfss_app` object that interfaces with the HFSS application.
   - The HFSS `ChangeProperty` API method is used to apply the updates.
   - Potential issues could arise if variable names in the dictionaries are invalid or if the dictionaries are not formatted correctly.

   Examples:
   ---------
   # Example to set design variables only
   set_all_variables_at_once({"Width": "10mm", "Height": "20mm"})

   # Example to set both design and project variables
   set_all_variables_at_once({"Width": "10mm", "Height": "20mm"}, {"$dielectric_constant_L1": "3.3", "$dielectric_constant_L2": "4.1"})
   """

local_variables = ["NAME:AllTabs",
        ["NAME:LocalVariableTab", ["NAME:PropServers", "LocalVariables"], ["NAME:ChangedProps"]]]

for key in design_variables.keys():
    local_variables[1][2].append(["NAME:" + key, "Value:=", design_variables[key]])

hfss_app.odesign.ChangeProperty(local_variables)

if project_variables:

    project_vars = ["NAME:AllTabs",
            ["NAME:ProjectVariableTab", ["NAME:PropServers", "ProjectVariables"], ["NAME:ChangedProps"]]]

    for key in design_variables.keys():
        project_vars[1][2].append(["NAME:" + key, "Value:=", project_variables[key]])

    hfss_app.odesign.ChangeProperty(local_variables)

Useful links and references

No response

@Dr-Hawal-R Dr-Hawal-R added the enhancement New features or code improvements label Dec 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New features or code improvements
Projects
None yet
Development

No branches or pull requests

1 participant