fix: align mechanical dynamic port validation
This commit is contained in:
1 parent
6a064892e2
commit
4e0b9fd8cc
7 files changed
+105
-7
No files matched your search
@@ -1129,14 +1129,29 @@ class AmesimLmechn1(AlgebraicComponent):
|
||||
raise ValueError(f"LMECHN1 {integer_name} must be an integer.")
|
||||
return cls(name=name, medium=medium, v1=parameters["v1"], sum=parameters["sum"])
|
||||
|
||||
@property
|
||||
def active_ports(self) -> tuple[str, ...]:
|
||||
return tuple(f"port_{index}" for index in range(1, self.v1 + 2))
|
||||
@classmethod
|
||||
def active_port_definitions_for_parameters(
|
||||
cls,
|
||||
parameters: Mapping[str, float],
|
||||
) -> tuple[PortDefinition, ...]:
|
||||
right_port_count = float(parameters["v1"])
|
||||
if not right_port_count.is_integer():
|
||||
raise ValueError("LMECHN1 v1 must be an integer.")
|
||||
count = int(right_port_count)
|
||||
if count < 1 or count > 20:
|
||||
raise ValueError("LMECHN1 v1 must be between 1 and 20.")
|
||||
return cls.PORTS[: count + 1]
|
||||
|
||||
@property
|
||||
def active_port_definitions(self) -> tuple[PortDefinition, ...]:
|
||||
return self.PORTS[: self.v1 + 1]
|
||||
|
||||
@property
|
||||
def active_ports(self) -> tuple[str, ...]:
|
||||
return tuple(
|
||||
definition.name for definition in self.active_port_definitions
|
||||
)
|
||||
|
||||
@property
|
||||
def reference_port_name(self) -> str:
|
||||
return f"port_{self.v1 + 1}"
|
||||
|
||||
Reference in new issue
Block a user