Skip to content

Commit 366df3d

Browse files
authored
Merge pull request #201 from EOMYS-Public/optimization
Optimization & DXF import
2 parents f3b6db8 + abf8d4d commit 366df3d

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

63 files changed

+2236
-180
lines changed

Tests/Classes/test_classes.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,8 @@ def test_class_as_dict(class_dict):
162162
d[prop["name"]] = None
163163
elif type(prop["value"]) is str and "()" in prop["value"]:
164164
d[prop["name"]] = eval(prop["value"] + ".as_dict()")
165+
elif prop["type"] == "complex":
166+
d[prop["name"]] = str(prop["value"])
165167
elif prop["type"] == "dict":
166168
if prop["value"] == "":
167169
d[prop["name"]] = {}

Tests/Methods/Geometry/test_Segment_meth.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@
7373
distance_test.append({"begin": -2, "end": 2, "Z": 2, "result": 0})
7474
distance_test.append({"begin": 2j, "end": 2, "Z": 1 + 1j, "result": 0})
7575
distance_test.append({"begin": 2j, "end": 2, "Z": 3 - 1j, "result": sqrt(2)})
76+
distance_test.append({"begin": 1 + 0j, "end": 0 + 1j, "Z": 0 + 192j, "result": 191})
7677

7778

7879
@pytest.mark.METHODS

Tests/Methods/Geometry/test_arc_meth.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1022,6 +1022,14 @@ def test_split_line(test_dict):
10221022
"D": abs(-1 - 2j - (-1j + exp(1j * 5 * pi / 4))),
10231023
}
10241024
)
1025+
# 12
1026+
D_test.append(
1027+
{
1028+
"arc": Arc2(center=0 + 0j, begin=1 + 0j, angle=pi / 2),
1029+
"Z": -4 - 2j, # First point of cutting line
1030+
"D": 5,
1031+
}
1032+
)
10251033

10261034

10271035
@pytest.mark.parametrize("test_dict", D_test)

Tests/Methods/Slot/test_HoleM50_meth.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ def test_comp_surface(self):
8383
)
8484
result = test_obj.hole[0].comp_surface()
8585
a = result
86-
b = 3.77977e-04
86+
b = 3.7803e-04
8787
assert abs((a - b) / a - 0) < DELTA
8888

8989
def test_comp_W5(self):

Tests/Plot/test_ICEM_2020.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -80,11 +80,11 @@ def test_FEMM_sym():
8080

8181
# FEMM files (mesh and results) are available in Results folder
8282
copyfile(
83-
join(out.path_res, "Femm", "fig_09_FEMM_sym_model.ans"),
83+
join(out.path_result, "Femm", "fig_09_FEMM_sym_model.ans"),
8484
join(save_path, "fig_09_FEMM_sym_model.ans"),
8585
)
8686
copyfile(
87-
join(out.path_res, "Femm", "fig_09_FEMM_sym_model.fem"),
87+
join(out.path_result, "Femm", "fig_09_FEMM_sym_model.fem"),
8888
join(save_path, "fig_09_FEMM_sym_model.fem"),
8989
)
9090

@@ -489,11 +489,11 @@ def test_ecc_FEMM():
489489

490490
# FEMM files (mesh and results) are available in Results folder
491491
copyfile(
492-
join(out.path_res, "Femm", "fig_19_Transform_list_model.ans"),
492+
join(out.path_result, "Femm", "fig_19_Transform_list_model.ans"),
493493
join(save_path, "fig_19_Transform_list_model.ans"),
494494
)
495495
copyfile(
496-
join(out.path_res, "Femm", "fig_19_Transform_list_model.fem"),
496+
join(out.path_result, "Femm", "fig_19_Transform_list_model.fem"),
497497
join(save_path, "fig_19_Transform_list_model.fem"),
498498
)
499499
# Plot, check, save

Tests/Validation/Optimization/test_Binh_and_Korn.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -75,8 +75,6 @@ def test_Binh_and_Korn():
7575
# simu.mag.Kgeo_fineness=0.02
7676
simu.struct = None
7777

78-
output = Output(simu=simu)
79-
8078
# ### Design variable
8179
my_vars = [
8280
OptiDesignVar(
@@ -139,7 +137,7 @@ def evaluate(output):
139137
# ### Defining the problem
140138

141139
my_prob = OptiProblem(
142-
output=output,
140+
simu=simu,
143141
design_var=my_vars,
144142
obj_func=objs,
145143
constraint=cstrs,

Tests/Validation/Optimization/test_opti_datakeeper_list.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,6 @@ def test_opti_datakeeper_list():
3535
# Definition of the simulation
3636
simu = Simu1(name="Test_machine", machine=SCIM_001)
3737

38-
output = Output(simu=simu)
39-
4038
# Design variable
4139
my_vars = [
4240
OptiDesignVar(
@@ -82,7 +80,7 @@ def evaluate(output):
8280

8381
# Defining the problem
8482
my_prob = OptiProblem(
85-
output=output,
83+
simu=simu,
8684
design_var=my_vars,
8785
obj_func=objs,
8886
datakeeper_list=datakeeper_list,

Tests/Validation/Optimization/test_opti_preprocessing.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,6 @@ def test_opti_preprocessing():
3535
# Definition of the simulation
3636
simu = Simu1(name="Test_machine", machine=SCIM_001)
3737

38-
output = Output(simu=simu)
39-
4038
# Design variable
4139
my_vars = [
4240
OptiDesignVar(
@@ -78,7 +76,7 @@ def evaluate(output):
7876

7977
# Defining the problem
8078
my_prob = OptiProblem(
81-
output=output,
79+
simu=simu,
8280
design_var=my_vars,
8381
obj_func=objs,
8482
preprocessing=preprocessing,

Tests/Validation/Optimization/test_zdt3.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,6 @@ def test_zdt3():
7474
# simu.mag.Kgeo_fineness=0.02
7575
simu.struct = None
7676

77-
output = Output(simu=simu)
78-
7977
# ### Design variable
8078
my_vars = []
8179

@@ -122,7 +120,7 @@ def evaluate(output):
122120

123121
# ### Defining the problem
124122
my_prob = OptiProblem(
125-
output=output, design_var=my_vars, obj_func=objs, eval_func=evaluate
123+
simu=simu, design_var=my_vars, obj_func=objs, eval_func=evaluate
126124
)
127125

128126
solver = OptiGenAlgNsga2Deap(problem=my_prob, size_pop=40, nb_gen=100, p_mutate=0.5)

Tests/Validation/Simulation/Multisimulation/test_slot_scale.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ def test_slot_scale():
6969
# Multi-simulation to variate the slot size
7070
multisim = VarParam(
7171
stop_if_error=True,
72+
is_reuse_femm_file=False,
7273
ref_simu_index=0, # Reference simulation is set as the first simulation from var_simu
7374
)
7475

@@ -116,10 +117,10 @@ def slot_scale(simu, scale_factor):
116117
error_keeper="lambda simu: np.nan",
117118
),
118119
DataKeeper(
119-
name="Airgap flux density components",
120+
name="Radial Airgap flux density",
120121
unit="H",
121122
symbol="B",
122-
keeper="lambda output: output.mag.B",
123+
keeper="lambda output: output.mag.B.components['radial'].get_along('time','angle')['B_r']",
123124
error_keeper=error_keeper_mag_flux,
124125
),
125126
]

0 commit comments

Comments
 (0)