Import of datasets / update of excitations (in Maxwell 2D + Circuit editor) using pyaedt

Dear all,

I would like to automate the simulation of my 3-phase PMSM electric motor using pyaedt.
Related to this, I have 3 questions:

Referring to the first picture:
a) What is the syntax to automatically import new datasets into Maxwell 2D (phase-voltages over time)?
b) What is the pyaedt- syntax to update (not initially create) a parameter of a winding group?

Referring to the second picture:
c) What is the pyaedt syntax to update the parameter names in an element (here: voltage source) of Maxwell Circuit editor?

I appreciate your feedback!
Thanks in adv ance.
BR
Richard

Tagged:

Answers

  • Giulia M.
    Giulia M. Member, Employee Posts: 14
    First Comment First Anniversary Ansys Employee First Answer

    Hi Richard,

    I will answer your questions by points:

    • To import 1d or 3d dataset in Maxwell there are two appropriate methods import_dataset1d or import_dataset3d. As an example, suppose that you already have an instance of Maxwell2d:
      m2d = Maxwell2d()
      m2d.import_dataset1d(filename)
      It requires the dataset in form of a .tab file.

    • Suppose that you have your winding group already in your design, you first have to retrieve the winding object and then you can access the properties to update. For example:
      m2d = Maxwell2d()
      wdg = [bound for bound in M2D.boundaries if bound.type == "Winding" and bound.name == winding_name][0]
      This last line shows you how to retrieve the winding object when you know upfront the winding name. I used here a list comprehension to parse all design's boundaries, then I filter them by type and by name.
      After you get your winding object you can access all its props as:
      wdg.props["Voltage"]
      and if you want to update one property you could do so by doing:
      wdg.props["Voltage"] = "1V"

    • If you'd like to update a property of one of your circuit components you can do so by accessing the components list through the modeler. Suppose you have your Circuit instance defined as:
      cir = MaxwellCircuit()
      if for example you want to update the name of your component you can do so by parsing all circuit's components:
      for k in cir.modeler.components.components.keys():
      if cir.modeler.components[k].InstanceName == "vout":
      cir.modeler.components[k].InstanceName = "test"
      components are stored as a dictionary in circuit modeler thus I'm looping through the keys of the dictionary.
      If you are not sure which property you can access you could always use the built in python method dir():
      dir(cir.modeler.components.components[key]).

    Hope this answer your questions, if not please do not hesitate to contact me.

    Kind regards,

    Giulia

  • Richard
    Richard Member Posts: 5
    First Comment

    Thanks a lot, that answered my question perfectly.

  • Richard
    Richard Member Posts: 5
    First Comment

    Hello Giulia,

    I tried your suggestions and while the first item was working smoothly, I encountered a problem when reading in the dataset:

    For testing purposes, I used a data-set from which I know it is working when red-in manually:

    Then, I tried to read it in by using the following code:

    Unfortunately, I get the following error-message:

    As you can see, the error message suggests that no data-set could be found (which is weird) and because it cannot find a data-set, it creates a new one. But when I check the existance of the newly created dataset, it seems non-existent.

    May you please help me with that - what is my fault?
    Thanks
    Richard

  • Giulia M.
    Giulia M. Member, Employee Posts: 14
    First Comment First Anniversary Ansys Employee First Answer

    Hi Richard,

    First of all I suggest to assign the dataset to a variable:
    dataset=m2d.import_dataset1d(file_path)
    in this way you can access the properties of the DataSet object and above all you can see if the method was successful in importing the dataset.
    In the second picture you specify the path and the name, without specifying if it's a project dataset. If you don't specify it by default is True thus the name will be preceded by $ symbol.
    In fact you can see in the second PyAEDT INFO that DataSet "$Test" was successfully created.
    It's a project dataset so, in order to retrieve it, you should use:
    m2d.project_datasets
    But if your intention is to get the DataSet object then I'll suggest to assign it to a variable.
    Finally, if you want to check whether the dataset exists then you can use dataset_exist(name) without the $ symbol.

    Hope this helps!

    Giulia

  • Richard
    Richard Member Posts: 5
    First Comment

    Hello Giulia,

    thanks a lot for your additional comments, now, it's working fine.
    Best regards
    Richard

  • Richard
    Richard Member Posts: 5
    First Comment

    Hello Giulia,

    I need to come back to your recommendation how to modify the MaxwellCircuit components.
    I tried the following:
    import pyaedt
    project_name='MyProject'
    design_name='TestDesign'
    Circuit_name='MyCircuit'
    (Note: The project, the design and the circuit are already existing, so I am not creating a new one)
    M2D=pyaedt.Maxwell2d(projectname=project_name,designname=design_name, new_desktop_session=False, non_graphical=False)
    cir=pyaedt.MaxwellCircuit(projectname=project_name, designname=Circuit_name)

    But now, when I try your recommendation, I find that cir.modeler does not have any attribute components:
    dir(cir.modeler.components) returns:"AttributeError: 'ModelerMaxwellCircuit' object has no attribute 'components'".

    May you please tell me what is the issue here?
    Thanks in advance.
    BR
    Richard

  • Giulia M.
    Giulia M. Member, Employee Posts: 14
    First Comment First Anniversary Ansys Employee First Answer

    Hi Richard,

    Thanks for getting back to us.
    Short answer is: if you'd like to get the list of components from a MaxwellCircuit design you could do so by: cir.modeler.schematic.components.
    You could use dir() for the modeler: dir(cir.modeler) or, if I recall correctly you use PyCharm, you could use the evaluator tool:

    and navigate through schematic to see what you could access:

    Hope this help!

    Kind regards,

    Giulia