def setup_arteries_ab(self, Ru, Rd, a, b, lam, k, Re, p0): """ Creates Artery objects using scaling parameters. :param Ru: Iterable containing upstream radii. :param Rd: Iterable containing downstream radii. :param a: Scaling parameter for daughter vessel. :param b: Scaling parameter for daughter vessel. :param lam: Iterable containing length-to-radius ratios. :param k: Iterable containing elasticity parameters. :param Re: Reynolds number. :param p0: initial pressure :raises: ValueError """ if type(Ru) == float: raise ValueError( "Parameter depth has to be equal to 1 if only one artery is specified." ) LAM = lam[0:len(Ru)] self.setup_arteries(Ru, Rd, LAM, k, Re, p0) pos = len(Ru) - 1 #pos = 0 #self.arteries[pos] = Artery(pos, Ru, Rd, lam, k, Re, p0) pos += 1 LAM = lam[pos] radii_u = Ru[1:pos] radii_d = Rd[1:pos] #radii_u = [Ru] #radii_d = [Rd] start = int(math.log((len(Ru) + 1), 2)) for i in range(start, self.depth): new_radii_u = [] new_radii_d = [] for i in range(len(radii_u)): ra_u = radii_u[i] * a rb_u = radii_u[i] * b ra_d = radii_d[i] * a rb_d = radii_d[i] * b self.arteries[pos] = Artery(pos, ra_u, ra_d, LAM, k, Re, p0) pos += 1 self.arteries[pos] = Artery(pos, rb_u, rb_d, LAM, k, Re, p0) pos += 1 new_radii_u.append(ra_u) new_radii_u.append(rb_u) new_radii_d.append(ra_d) new_radii_d.append(rb_d) radii_u = new_radii_u radii_d = new_radii_d
def setup_arteries(self, Ru, Rd, lam, k, Re): """ Creates Artery objects. :param Ru: Iterable containing upstream radii. :param Rd: Iterable containing downstream radii. :param lam: Iterable containing length-to-radius ratios. :param k: Iterable containing elasticity parameters. :param Re: Reynolds number. """ for i in range(len(Ru)): self.arteries[i] = Artery(i, Ru[i], Rd[i], lam[i], k, Re)
def setup_arteries_ab(self, Ru, Rd, a, b, lam, k, Re): """ Creates Artery objects using scaling parameters. :param Ru: Iterable containing upstream radii. :param Rd: Iterable containing downstream radii. :param a: Scaling parameter for daughter vessel. :param b: Scaling parameter for daughter vessel. :param lam: Iterable containing length-to-radius ratios. :param k: Iterable containing elasticity parameters. :param Re: Reynolds number. :raises: ValueError """ if type(Ru) == float: raise ValueError( "Parameter depth has to be equal to 1 if only one artery is specified." ) pos = 0 self.arteries[pos] = Artery(pos, Ru, Rd, lam, k, Re) pos += 1 radii_u = [Ru] radii_d = [Rd] for i in range(1, self.depth): new_radii_u = [] new_radii_d = [] for i in range(len(radii_u)): ra_u = radii_u[i] * a rb_u = radii_u[i] * b ra_d = radii_d[i] * a rb_d = radii_d[i] * b self.arteries[pos] = Artery(pos, ra_u, ra_d, lam, k, Re) pos += 1 self.arteries[pos] = Artery(pos, ra_u, ra_d, lam, k, Re) pos += 1 new_radii_u.append(ra_u) new_radii_u.append(rb_u) new_radii_d.append(ra_d) new_radii_d.append(rb_d) radii_u = new_radii_u radii_d = new_radii_d
def __init__(self, Ru, Rd, lam, k, rho, nu, p0, depth, ntr, Re, **kwargs): """ ArteryNetwork constructor. """ self._depth = depth self._arteries = [0] * (2**depth - 1) if depth == 1: self.arteries[0] = Artery(0, Ru, Rd, lam, k, Re, p0) elif 'a' in kwargs: self.setup_arteries_ab(Ru, Rd, kwargs['a'], kwargs['b'], lam, k, Re, p0) else: self.setup_arteries(Ru, Rd, lam, k, Re, p0) self._t = 0.0 self._ntr = ntr self._progress = 0 self._rho = rho self._nu = nu self._p0 = p0