Skip to content

Fix/choke generation #913

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 4 commits into from
Mar 3, 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
21 changes: 14 additions & 7 deletions _unittest/test_08_Primitives3D.py
Original file line number Diff line number Diff line change
Expand Up @@ -1053,13 +1053,20 @@ def test_72_check_choke_values(self):
choke_file5 = os.path.join(local_path, "example_models", "choke_json_file", "choke_4winding_3Layer_Linked.json")
choke_file6 = os.path.join(local_path, "example_models", "choke_json_file", "choke_1winding_3Layer_Linked.json")
choke_file7 = os.path.join(local_path, "example_models", "choke_json_file", "choke_2winding_2Layer_Common.json")
resolve1 = self.aedtapp.modeler.check_choke_values(choke_file1, create_another_file=True)
resolve2 = self.aedtapp.modeler.check_choke_values(choke_file2, create_another_file=True)
resolve3 = self.aedtapp.modeler.check_choke_values(choke_file3, create_another_file=True)
resolve4 = self.aedtapp.modeler.check_choke_values(choke_file4, create_another_file=True)
resolve5 = self.aedtapp.modeler.check_choke_values(choke_file5, create_another_file=True)
resolve6 = self.aedtapp.modeler.check_choke_values(choke_file6, create_another_file=True)
resolve7 = self.aedtapp.modeler.check_choke_values(choke_file7, create_another_file=True)
scratch_choke_file1 = self.local_scratch.copyfile(choke_file1)
scratch_choke_file2 = self.local_scratch.copyfile(choke_file2)
scratch_choke_file3 = self.local_scratch.copyfile(choke_file3)
scratch_choke_file4 = self.local_scratch.copyfile(choke_file4)
scratch_choke_file5 = self.local_scratch.copyfile(choke_file5)
scratch_choke_file6 = self.local_scratch.copyfile(choke_file6)
scratch_choke_file7 = self.local_scratch.copyfile(choke_file7)
resolve1 = self.aedtapp.modeler.check_choke_values(scratch_choke_file1, create_another_file=True)
resolve2 = self.aedtapp.modeler.check_choke_values(scratch_choke_file2, create_another_file=True)
resolve3 = self.aedtapp.modeler.check_choke_values(scratch_choke_file3, create_another_file=True)
resolve4 = self.aedtapp.modeler.check_choke_values(scratch_choke_file4, create_another_file=True)
resolve5 = self.aedtapp.modeler.check_choke_values(scratch_choke_file5, create_another_file=True)
resolve6 = self.aedtapp.modeler.check_choke_values(scratch_choke_file6, create_another_file=True)
resolve7 = self.aedtapp.modeler.check_choke_values(scratch_choke_file7, create_another_file=True)
assert isinstance(resolve1, list)
assert resolve1[0]
assert isinstance(resolve1[1], dict)
Expand Down
10 changes: 5 additions & 5 deletions pyaedt/modeler/Primitives3D.py
Original file line number Diff line number Diff line change
Expand Up @@ -1593,9 +1593,9 @@ def create_choke(self, json_file):
>>> dictionary_values = hfss.modeler.check_choke_values("C:/Example/Of/Path/myJsonFile.json")
>>> mychoke = hfss.modeler.create_choke("C:/Example/Of/Path/myJsonFile_Corrected.json")
"""
json_file = open(json_file, "r")
values = json.load(json_file)
self.logger.info("CHOKE INFO" + str(values))
with open(json_file, "r") as read_file:
values = json.load(read_file)
self.logger.info("CHOKE INFO: " + str(values))

security_factor = 1.1
sr = security_factor
Expand Down Expand Up @@ -2139,8 +2139,8 @@ def check_choke_values(self, json_file, create_another_file=True):
are_inequations_checkable = True
security_factor = 1.1
sr = security_factor
read_file = open(json_file, "r")
values = json.load(read_file)
with open(json_file, "r") as read_file:
values = json.load(read_file)

for key, value in dictionary_model.items():
if key not in values:
Expand Down