Skip to content

Commit

Permalink
[NF] Rework VarLoadCurrent/Voltage, InputVoltage/Current and OP/OPdq/…
Browse files Browse the repository at this point in the history
…OPslip classes
  • Loading branch information
EmileDvs committed Dec 2, 2021
1 parent 967595d commit 1ab7916
Show file tree
Hide file tree
Showing 37 changed files with 995 additions and 697 deletions.
87 changes: 60 additions & 27 deletions pyleecan/Classes/Class_Dict.json
Original file line number Diff line number Diff line change
Expand Up @@ -4045,6 +4045,15 @@
"type": "OP",
"unit": "-",
"value": null
},
{
"desc": "To enforce final time",
"max": "",
"min": "",
"name": "t_final",
"type": "float",
"unit": "",
"value": null
}
]
},
Expand Down Expand Up @@ -4226,7 +4235,8 @@
"is_internal": false,
"methods": [
"gen_input",
"set_OP_from_array"
"set_OP_from_array",
"set_Ud_Uq"
],
"mother": "Input",
"name": "InputVoltage",
Expand Down Expand Up @@ -7608,8 +7618,8 @@
"get_slip",
"get_Ud_Uq",
"set_Id_Iq",
"set_I0_Phi0",
"get_I0_Phi0"
"get_I0_Phi0",
"set_Ud_Uq"
],
"mother": "OP",
"name": "OPdq",
Expand Down Expand Up @@ -7672,7 +7682,8 @@
"set_Id_Iq",
"get_I0_Phi0",
"get_slip",
"set_I0_Phi0"
"set_I0_Phi0",
"set_Ud_Uq"
],
"mother": "OP",
"name": "OPslip",
Expand Down Expand Up @@ -13583,7 +13594,8 @@
}
],
"daughters": [
"VarLoadCurrent"
"VarLoadCurrent",
"VarLoadVoltage"
],
"desc": "Abstract class to generate multi-simulation by changing the operating point",
"is_internal": false,
Expand All @@ -13594,28 +13606,6 @@
"name": "VarLoad",
"package": "Simulation",
"path": "pyleecan/Generator/ClassesRef/Simulation/VarLoad.csv",
"properties": []
},
"VarLoadCurrent": {
"constants": [
{
"name": "VERSION",
"value": "1"
}
],
"daughters": [],
"desc": "Generate a multisimulation with InputCurrent at variable operating point",
"is_internal": false,
"methods": [
"get_input_list",
"generate_simulation_list",
"check_param",
"get_elec_datakeeper"
],
"mother": "VarLoad",
"name": "VarLoadCurrent",
"package": "Simulation",
"path": "pyleecan/Generator/ClassesRef/Simulation/VarLoadCurrent.csv",
"properties": [
{
"desc": "Operating point matrix (N0,I0,Phi0,T,P) or (N0,Id,Iq,T,P) ",
Expand Down Expand Up @@ -13655,6 +13645,48 @@
}
]
},
"VarLoadCurrent": {
"constants": [
{
"name": "VERSION",
"value": "1"
}
],
"daughters": [],
"desc": "Generate a multisimulation with InputCurrent at variable operating point",
"is_internal": false,
"methods": [
"get_input_list",
"generate_simulation_list",
"get_elec_datakeeper"
],
"mother": "VarLoad",
"name": "VarLoadCurrent",
"package": "Simulation",
"path": "pyleecan/Generator/ClassesRef/Simulation/VarLoadCurrent.csv",
"properties": []
},
"VarLoadVoltage": {
"constants": [
{
"name": "VERSION",
"value": "1"
}
],
"daughters": [],
"desc": "Generate a multisimulation with InputVoltage at variable operating point",
"is_internal": false,
"methods": [
"generate_simulation_list",
"get_elec_datakeeper",
"get_input_list"
],
"mother": "VarLoad",
"name": "VarLoadVoltage",
"package": "Simulation",
"path": "pyleecan/Generator/ClassesRef/Simulation/VarLoadVoltage.csv",
"properties": []
},
"VarParam": {
"constants": [
{
Expand Down Expand Up @@ -13700,6 +13732,7 @@
"daughters": [
"VarLoad",
"VarLoadCurrent",
"VarLoadVoltage",
"VarParam"
],
"desc": "Abstract class for the multi-simulation",
Expand Down
30 changes: 30 additions & 0 deletions pyleecan/Classes/Input.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ def __init__(
Nrev=None,
Na_tot=2048,
OP=None,
t_final=None,
init_dict=None,
init_str=None,
):
Expand Down Expand Up @@ -138,6 +139,8 @@ def __init__(
Na_tot = init_dict["Na_tot"]
if "OP" in list(init_dict.keys()):
OP = init_dict["OP"]
if "t_final" in list(init_dict.keys()):
t_final = init_dict["t_final"]
# Set the properties (value check and convertion are done in setter)
self.parent = None
self.time = time
Expand All @@ -146,6 +149,7 @@ def __init__(
self.Nrev = Nrev
self.Na_tot = Na_tot
self.OP = OP
self.t_final = t_final

# The class is frozen, for now it's impossible to add new properties
self._freeze()
Expand Down Expand Up @@ -176,6 +180,7 @@ def __str__(self):
Input_str += "OP = " + tmp
else:
Input_str += "OP = None" + linesep + linesep
Input_str += "t_final = " + str(self.t_final) + linesep
return Input_str

def __eq__(self, other):
Expand All @@ -195,6 +200,8 @@ def __eq__(self, other):
return False
if other.OP != self.OP:
return False
if other.t_final != self.t_final:
return False
return True

def compare(self, other, name="self", ignore_list=None):
Expand Down Expand Up @@ -229,6 +236,8 @@ def compare(self, other, name="self", ignore_list=None):
diff_list.append(name + ".OP None mismatch")
elif self.OP is not None:
diff_list.extend(self.OP.compare(other.OP, name=name + ".OP"))
if other._t_final != self._t_final:
diff_list.append(name + ".t_final")
# Filter ignore differences
diff_list = list(filter(lambda x: x not in ignore_list, diff_list))
return diff_list
Expand All @@ -243,6 +252,7 @@ def __sizeof__(self):
S += getsizeof(self.Nrev)
S += getsizeof(self.Na_tot)
S += getsizeof(self.OP)
S += getsizeof(self.t_final)
return S

def as_dict(self, type_handle_ndarray=0, keep_function=False, **kwargs):
Expand Down Expand Up @@ -284,6 +294,7 @@ def as_dict(self, type_handle_ndarray=0, keep_function=False, **kwargs):
keep_function=keep_function,
**kwargs
)
Input_dict["t_final"] = self.t_final
# The class name is added to the dict for deserialisation purpose
Input_dict["__class__"] = "Input"
return Input_dict
Expand All @@ -300,6 +311,7 @@ def _set_None(self):
self.Na_tot = None
if self.OP is not None:
self.OP._set_None()
self.t_final = None

def _get_time(self):
"""getter of time"""
Expand Down Expand Up @@ -451,3 +463,21 @@ def _set_OP(self, value):
:Type: OP
""",
)

def _get_t_final(self):
"""getter of t_final"""
return self._t_final

def _set_t_final(self, value):
"""setter of t_final"""
check_var("t_final", value, "float")
self._t_final = value

t_final = property(
fget=_get_t_final,
fset=_set_t_final,
doc=u"""To enforce final time
:Type: float
""",
)
4 changes: 4 additions & 0 deletions pyleecan/Classes/InputCurrent.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ def __init__(
Nrev=None,
Na_tot=2048,
OP=None,
t_final=None,
init_dict=None,
init_str=None,
):
Expand Down Expand Up @@ -147,6 +148,8 @@ def __init__(
Na_tot = init_dict["Na_tot"]
if "OP" in list(init_dict.keys()):
OP = init_dict["OP"]
if "t_final" in list(init_dict.keys()):
t_final = init_dict["t_final"]
# Set the properties (value check and convertion are done in setter)
self.Is = Is
self.Ir = Ir
Expand All @@ -163,6 +166,7 @@ def __init__(
Nrev=Nrev,
Na_tot=Na_tot,
OP=OP,
t_final=t_final,
)
# The class is frozen (in InputVoltage init), for now it's impossible to
# add new properties
Expand Down
4 changes: 4 additions & 0 deletions pyleecan/Classes/InputFlux.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ def __init__(
Nrev=None,
Na_tot=2048,
OP=None,
t_final=None,
init_dict=None,
init_str=None,
):
Expand Down Expand Up @@ -135,6 +136,8 @@ def __init__(
Na_tot = init_dict["Na_tot"]
if "OP" in list(init_dict.keys()):
OP = init_dict["OP"]
if "t_final" in list(init_dict.keys()):
t_final = init_dict["t_final"]
# Set the properties (value check and convertion are done in setter)
self.per_a = per_a
self.per_t = per_t
Expand All @@ -159,6 +162,7 @@ def __init__(
Nrev=Nrev,
Na_tot=Na_tot,
OP=OP,
t_final=t_final,
)
# The class is frozen (in InputCurrent init), for now it's impossible to
# add new properties
Expand Down
11 changes: 10 additions & 1 deletion pyleecan/Classes/InputForce.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ def __init__(
Nrev=None,
Na_tot=2048,
OP=None,
t_final=None,
init_dict=None,
init_str=None,
):
Expand Down Expand Up @@ -93,11 +94,19 @@ def __init__(
Na_tot = init_dict["Na_tot"]
if "OP" in list(init_dict.keys()):
OP = init_dict["OP"]
if "t_final" in list(init_dict.keys()):
t_final = init_dict["t_final"]
# Set the properties (value check and convertion are done in setter)
self.P = P
# Call Input init
super(InputForce, self).__init__(
time=time, angle=angle, Nt_tot=Nt_tot, Nrev=Nrev, Na_tot=Na_tot, OP=OP
time=time,
angle=angle,
Nt_tot=Nt_tot,
Nrev=Nrev,
Na_tot=Na_tot,
OP=OP,
t_final=t_final,
)
# The class is frozen (in Input init), for now it's impossible to
# add new properties
Expand Down
27 changes: 26 additions & 1 deletion pyleecan/Classes/InputVoltage.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,11 @@
except ImportError as error:
set_OP_from_array = error

try:
from ..Methods.Simulation.InputVoltage.set_Ud_Uq import set_Ud_Uq
except ImportError as error:
set_Ud_Uq = error


from ..Classes.ImportMatrixVal import ImportMatrixVal
from numpy import ndarray
Expand Down Expand Up @@ -66,6 +71,17 @@ class InputVoltage(Input):
)
else:
set_OP_from_array = set_OP_from_array
# cf Methods.Simulation.InputVoltage.set_Ud_Uq
if isinstance(set_Ud_Uq, ImportError):
set_Ud_Uq = property(
fget=lambda x: raise_(
ImportError(
"Can't use InputVoltage method set_Ud_Uq: " + str(set_Ud_Uq)
)
)
)
else:
set_Ud_Uq = set_Ud_Uq
# save and copy methods are available in all object
save = save
copy = copy
Expand All @@ -85,6 +101,7 @@ def __init__(
Nrev=None,
Na_tot=2048,
OP=None,
t_final=None,
init_dict=None,
init_str=None,
):
Expand Down Expand Up @@ -125,6 +142,8 @@ def __init__(
Na_tot = init_dict["Na_tot"]
if "OP" in list(init_dict.keys()):
OP = init_dict["OP"]
if "t_final" in list(init_dict.keys()):
t_final = init_dict["t_final"]
# Set the properties (value check and convertion are done in setter)
self.rot_dir = rot_dir
self.angle_rotor_initial = angle_rotor_initial
Expand All @@ -133,7 +152,13 @@ def __init__(
self.current_dir = current_dir
# Call Input init
super(InputVoltage, self).__init__(
time=time, angle=angle, Nt_tot=Nt_tot, Nrev=Nrev, Na_tot=Na_tot, OP=OP
time=time,
angle=angle,
Nt_tot=Nt_tot,
Nrev=Nrev,
Na_tot=Na_tot,
OP=OP,
t_final=t_final,
)
# The class is frozen (in Input init), for now it's impossible to
# add new properties
Expand Down
Loading

0 comments on commit 1ab7916

Please sign in to comment.