mirror of https://gitlab.com/pamhyr/pamhyr2
BC: Add some implementation of model BC.
parent
35d66cc881
commit
81b8fd67a6
|
|
@ -9,7 +9,9 @@ class BoundaryCondition(object):
|
||||||
self._name = name
|
self._name = name
|
||||||
self._type = ""
|
self._type = ""
|
||||||
self._node = None
|
self._node = None
|
||||||
self._data = None
|
self._data = []
|
||||||
|
self.header = []
|
||||||
|
self.types = [int, float]
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def name(self):
|
def name(self):
|
||||||
|
|
@ -34,5 +36,64 @@ class BoundaryCondition(object):
|
||||||
def has_node(self):
|
def has_node(self):
|
||||||
return self._node is not None
|
return self._node is not None
|
||||||
|
|
||||||
|
@property
|
||||||
|
def header(self):
|
||||||
|
return self._header.copy()
|
||||||
|
|
||||||
|
@property
|
||||||
|
def data(self):
|
||||||
|
return self._data.copy()
|
||||||
|
|
||||||
def is_define(self):
|
def is_define(self):
|
||||||
return self._data is not None
|
return self._data is not None
|
||||||
|
|
||||||
|
def add(self, index:int):
|
||||||
|
value = (self.default_0, self_default_1)
|
||||||
|
self._data.insert(index, value)
|
||||||
|
|
||||||
|
def insert(self, index:int, value):
|
||||||
|
self._data.insert(index, value)
|
||||||
|
|
||||||
|
def delete(self, indexes):
|
||||||
|
self._data = list(
|
||||||
|
map(
|
||||||
|
lambda e: e[1],
|
||||||
|
filter(
|
||||||
|
lambda e: e[0] not in indexes,
|
||||||
|
enumerate(self.data)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
def sort(self, _reverse):
|
||||||
|
self._data.sort(reverse=_reverse)
|
||||||
|
|
||||||
|
def _set_i_c_v(self, index, column, value):
|
||||||
|
v = list(self._data[index])
|
||||||
|
v[column] = self.types[column](value)
|
||||||
|
self._data[index] = tuple(v)
|
||||||
|
|
||||||
|
def set_i_0(self, index:int, value):
|
||||||
|
self._set_i_c_v(index, 0, value):
|
||||||
|
|
||||||
|
def set_i_1(self, index:int, value):
|
||||||
|
self._set_i_c_v(index, 1, value):
|
||||||
|
|
||||||
|
def convert(self, cls):
|
||||||
|
new = cls(name = self.name)
|
||||||
|
for i, _ in self.data:
|
||||||
|
new.add(i)
|
||||||
|
|
||||||
|
for i in [0,1]:
|
||||||
|
for j in [0,1]:
|
||||||
|
if self.header[i] == new.header[j]:
|
||||||
|
for ind, v in self.data:
|
||||||
|
new._set_i_c_v(ind, j, v[i])
|
||||||
|
|
||||||
|
return new
|
||||||
|
|
||||||
|
def _default_0(self):
|
||||||
|
return self.types[0](0)
|
||||||
|
|
||||||
|
def _default_1(self):
|
||||||
|
return self.types[1](0.0)
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,44 @@
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
|
from Model.Except import NotImplementedMethodeError
|
||||||
|
|
||||||
|
from Model.BoundaryCondition.BoundaryCondition import BoundaryCondition
|
||||||
|
|
||||||
|
BC_types = [
|
||||||
|
"PC",
|
||||||
|
"TZ",
|
||||||
|
"TD",
|
||||||
|
"ZD"
|
||||||
|
]
|
||||||
|
|
||||||
|
class PonctualContribution(BoundaryCondition):
|
||||||
|
def __init__(self, name:str = ""):
|
||||||
|
super(PonctualContribution, self).__init__(name=name)
|
||||||
|
|
||||||
|
self._type = "PC"
|
||||||
|
self._header = ["time", "debit"]
|
||||||
|
|
||||||
|
class TimeOverZ(BoundaryCondition):
|
||||||
|
def __init__(self, name:str = ""):
|
||||||
|
super(PonctualContribution, self).__init__(name=name)
|
||||||
|
|
||||||
|
self._type = "TZ"
|
||||||
|
self._header = ["time", "z"]
|
||||||
|
|
||||||
|
class TimeOverDebit(BoundaryCondition):
|
||||||
|
def __init__(self, name:str = ""):
|
||||||
|
super(PonctualContribution, self).__init__(name=name)
|
||||||
|
|
||||||
|
self._type = "TD"
|
||||||
|
self._header = ["time", "debit"]
|
||||||
|
|
||||||
|
class ZOverDebit(BoundaryCondition):
|
||||||
|
def __init__(self, name:str = ""):
|
||||||
|
super(PonctualContribution, self).__init__(name=name)
|
||||||
|
|
||||||
|
self._type = "ZD"
|
||||||
|
self._header = ["z", "debit"]
|
||||||
|
self._types = [float, float]
|
||||||
|
|
||||||
|
def _default_0(self):
|
||||||
|
return 0.0
|
||||||
Loading…
Reference in New Issue