def plotPO2YProfile(simParams, x=150e-6, **kwargs): kroghSol = KroghSolution2DCone(simParams) kroghSol.intravascularResistanceLDHalf = kwargs.get( 'K0', kroghSol.intravascularResistanceLDHalf) kroghSol.convO2Transport = kwargs.get('convO2Transport', True) if 'K0' in kwargs: print "plotPO2Profile: Using K0 = %g" % kwargs['K0'] style = kwargs.get('style', {'color': 'k'}) PO2AnalyticalStyle = { 'color': 'k', 'linestyle': '-', 'linewidth': 1, 'dashes': (1.2, 1.5) } # 'dashes': (5,2.5,1,2.5)} nr = 300 rMax = kroghSol.geometry.tissueRadius(x) rAnalytical = np.linspace(0, rMax, nr) rTissue = np.linspace(kroghSol.geometry['radiusWall'], rMax, nr) PO2Analytical = [kroghSol.PO2Analytical(x, r) for r in rAnalytical] PO2Tissue = [kroghSol.PO2Tissue(x, r) for r in rTissue] PO2RBCMean = kroghSol.PO2RBCMeanAtX(x) plt.plot(1e6 * rAnalytical, PO2Analytical, **PO2AnalyticalStyle) plt.plot(1e6 * rTissue, PO2Tissue, linewidth=1, **style) plt.plot(1e6 * kroghSol.Rrbc / 2, PO2RBCMean, '.', color='k', markersize=4) plt.xlim(0, 1e6 * rMax) plt.ylim(rounded_bounds(PO2Analytical, 10)) labels.setXLabel('r', 'um') labels.setYLabel('PO2', 'mmHg')
def plotPO2ProfileInterstitialSpace(simParams, radius=17.6e-6, **kwargs): kroghSol = KroghSolution2DCone(simParams) kroghSol.intravascularResistanceLDHalf = kwargs.get( 'K0', kroghSol.intravascularResistanceLDHalf) if 'K0' in kwargs: print "plotPO2Profile: Using K0 = %g" % kwargs['K0'] style = kwargs.get('style', {'color': 'k'}) L = simParams['domainLength'] nx = 100 xValues = np.linspace(0, L, nx) PO2 = [kroghSol.PO2Tissue(x, radius) for x in xValues] plt.plot(1e6 * xValues, PO2, linewidth=1, **style) plt.ylim(rounded_bounds(PO2, 10)) interstitialLayerWidth = 0.35e-6 kroghSol.geometry['radiusWall'] += interstitialLayerWidth kroghSol.intravascularResistanceLDHalf *= 1.1 PO2WithInterstitial = [kroghSol.PO2Tissue(x, radius) for x in xValues] plt.plot(1e6 * xValues, PO2WithInterstitial, '--') labels.setXLabel('x', 'um') labels.setYLabel('PO2', 'mmHg') print 'Difference: ', np.array(PO2) - np.array(PO2WithInterstitial)
def compute_PO2RBCInlet(self): from HbO2.model.kroghSolution import KroghSolution2DCone kroghSol = KroghSolution2DCone(self) if 'HbInlet' in self.keys(): self['PO2RBCInlet'] = kroghSol.chem.hillP(self['HbInlet']) elif 'PO2RBCInlet' in self and 'HbInlet' not in self: self['HbInlet'] = kroghSol.chem.hillS(self['PO2RBCInlet'])
def __init__(self, simParams, interactionModel): """ Object initialization. Args: simParams: instance of IOHbO2ParametersAxisymmetric interactionModel: model for the diffusive interaction (instance of DiffusiveInteractionModel) """ self.simParams = simParams self.kroghSol = KroghSolution2DCone(simParams) self.interactionModel = interactionModel try: self.inletHb = np.array( [simParams['HbInlet1'], simParams['HbInlet2']]) except KeyError: self.inletHb = simParams['HbInlet'] * np.ones((2, )) try: self._read_vrbc_from_path_generator() except ValueError: print "Using the RBC velocity from the SimulationParameters object." self.v_rbc = simParams['RBCVelocity'] * np.ones((2, )) try: self._read_ld_from_path_generator() except ValueError: print "Using the linear density from the SimulationParameters object." self.ld = simParams['LDMean'] * np.ones((2, )) self.kroghSolCap0 = copy.deepcopy(self.kroghSol) self.kroghSolCap0.vRBC = self.v_rbc[0] self.kroghSolCap0.LD = self.ld[0] self.kroghSolCap1 = copy.deepcopy(self.kroghSol) self.kroghSolCap1.vRBC = self.v_rbc[1] self.kroghSolCap1.LD = self.ld[1]
def __init__(self, sim_params): """ Args: sim_params (SimulationParameters): """ self.sim_params = sim_params self.krogh_sol = KroghSolution2DCone(sim_params)
def __init__(self, decorated, **kwargs): super(PO2DropPostProcessor, self).__init__(decorated) self.sampled_set = SampledSet(self.case_path, kwargs['sampledSetDir']) self.wall_set_name = kwargs['wallSetName'] self.tissue_set_name = kwargs['tissueSetName'] self.sampled_field = kwargs['sampledField'] self.tissue_wall_distance = kwargs['tissueWallDistance'] self.probe_index = kwargs['probeIndex'] self.r = self.simParams.geometry( )['radiusWall'] + kwargs['tissueWallDistance'] self.x = self.sampled_set.last_time_values( self.tissue_set_name, self.sampled_field)[self.probe_index, 0] self._krogh_sol = KroghSolution2DCone(self.simParams)
def setParamValues(self, simParams, values): super(LDM0ParameterStudyConstantMiddlePO2, self).setParamValues(simParams, values) from HbO2.model.kroghSolution import KroghSolution2DCone kroghSol = KroghSolution2DCone(simParams) xMiddle = 0.5 * simParams.geometry()['domainLength'] hbMiddle = kroghSol.chem.hillS(self['PO2Middle']) hbInlet = kroghSol.saturationAtXWithO2ConvectionAndInitialCondition( xMiddle, hbMiddle, 0) PO2RBCInlet = kroghSol.chem.hillP(hbInlet) if PO2RBCInlet > self['PO2InletMax']: warnings.warn('RBC PO2 at the inlet is clamped to {:g}'.format( self['PO2InletMax'])) simParams['PO2RBCInlet'] = min(PO2RBCInlet, self['PO2InletMax']) simParams.update_files()
def plotPO2Profile(simParams, radius=17.6e-6, **kwargs): kroghSol = KroghSolution2DCone(simParams) kroghSol.intravascularResistanceLDHalf = kwargs.get( 'K0', kroghSol.intravascularResistanceLDHalf) if 'K0' in kwargs: print "plotPO2Profile: Using K0 = %g" % kwargs['K0'] kroghSol.convO2Transport = kwargs.get('convO2Transport', True) style = kwargs.get('style', {'color': 'k'}) L = simParams['domainLength'] nx = 100 xValues = np.linspace(0, L, nx) PO2 = [kroghSol.PO2Tissue(x, radius) for x in xValues] plt.plot(1e6 * xValues, PO2, linewidth=1, **style) labels.setXLabel('x', 'um') labels.setYLabel('PO2', 'mmHg')
def __init__(self, decorated, **kwargs): super(LDvRBCParameterStudyPostProcessor, self).__init__(decorated) self.sampledSetDir = kwargs.get('sampledSetDir') self.sampledSetName = kwargs.get('sampledSetName') self.sampledField = kwargs.get('sampledField') self.xFit = kwargs.get('xFit') self.rFit = kwargs.get('rFit') self.probeSpacing = kwargs.get('probeSpacing') convO2Transport = kwargs.get('convO2Transport', True) self.kroghSols = [KroghSolution2DCone(IOHbO2ParametersAxisymmetric(p)) for p in self.param_study.casePaths()] for ks in self.kroghSols: ks.convO2Transport = convO2Transport simParams = IOHbO2ParametersAxisymmetric(self.param_study.casePaths()[0]) domainLength = simParams['domainLength'] self.probeIdx = int(np.round(self.xFit/self.probeSpacing)) self.probePositions = np.arange(0, domainLength + 1e-6, self.probeSpacing) self.probeNames = ['x={:g}um'.format(1e6*x) for x in self.probePositions]
def compute(self): """ Compute the hemoglobin saturation at all nodes in the given graph. The results are stored in the attribute 'hb' of each vertex and in the attributes 'upstream_hb' and 'downstream_hb' of each edge. This method accomodates distributions of hemoglobin saturation at each node. The distribution at a node is described by a list of IntegratedHemoglobinAtVertex objects. """ integration_edge_seq = directed_integration_ordering(self.graph) self.graph.es['upstream_hb'] = None self.graph.es['downstream_hb'] = None self.graph.es['hb_distribution'] = None for edge in integration_edge_seq: edge['upstream_hb'] = self.upstream_hb(edge) self.graph.vs[edge.tuple[0]]['hb'] = edge['upstream_hb'] if edge['rbc_flow'] == 0.0: warnings.warn('The edge {:d} has zero flow'.format( edge['edge_index'])) edge['rbc_flow'] = 1e-6 # to avoid division by zero downstream_hb = [] for upstream_int_hb in edge['upstream_hb']: krogh_sol = KroghSolution2DCone( self._edge_sim_params(edge, upstream_int_hb.hb)) length = krogh_sol.geometry['domainLength'] transit_time = length / krogh_sol.vRBC hb_v = krogh_sol.saturationAtX(length) distal_coord = upstream_int_hb.coordinate + length distal_time = upstream_int_hb.transit_time + transit_time downstream_hb.append( IntegratedHemoglobinAtVertex(hb_v, weight=upstream_int_hb.weight, coordinate=distal_coord, transit_time=distal_time)) edge['downstream_hb'] = downstream_hb edge['hb_distribution'] = HemoglobinDistributionOnEdge( edge, edge['upstream_hb'], edge['downstream_hb']) self.graph.vs[edge.tuple[1]]['hb'] = edge['downstream_hb'] self._compute_mean_hb()
def plotHbProfile(simParams, **kwargs): kroghSol = KroghSolution2DCone(simParams) kroghSol.intravascularResistanceLDHalf = kwargs.get( 'K0', kroghSol.intravascularResistanceLDHalf) style = kwargs.get('style', {'color': 'k'}) L = kroghSol.geometry['domainLength'] nx = 100 xValues = np.linspace(0, L, nx) # kroghSol.convO2Transport = False # HbSimplified = kroghSol.saturationAtX(xValues, LD, vRBC) # print "S at x = %g: %g (simplified)" % (x, kroghSol.saturationAtX(x, LD, vRBC)) kroghSol.convO2Transport = True Hb = kroghSol.saturationAtXWithO2Convection(xValues) x = L print "S at x = %g: %g" % (x, kroghSol.saturationAtX(x)) # plt.plot(1e6*xValues, HbSimplified, color='r', linestyle='-') plt.plot(1e6 * xValues, Hb, linewidth=1, **style) plt.xlim(0, 1e6 * simParams['domainLength']) labels.setXLabel('x', 'um') labels.setYLabel('S')
def __init__(self, postProcessor): """ Initialize an instance: constructs the attribute kroghSol and choose the radius for plotting PO2 as a function of the geometry. Args: postProcessor (LDvRBCParameterStudyPostProcessor): postprocessor for plotting """ self.postProcessor = postProcessor simParams = IOHbO2ParametersAxisymmetric( self.postProcessor.param_study['baseCasePath']) self.kroghSol = KroghSolution2DCone(simParams) self.kroghSol.convO2Transport = self.postProcessor.kroghSols[ 0].convO2Transport if simParams.geometry().isGlomerulus(): self.R = 12.6e-6 self.PO2Levels = np.arange(0., 80., 8) self.PO2Levels[0] = 2.0 else: self.R = 17.6e-6 self.PO2Levels = np.arange(0., 80., 8) self.PO2Levels[0] = 2.0 self.cmap = plt.cm.jet
def compute_HbInit(self): from HbO2.model.kroghSolution import KroghSolution2DCone kroghSol = KroghSolution2DCone(self) self['HbInit'] = kroghSol.averageSaturation()
def compute_PO2PlasmaInlet(self): from HbO2.model.kroghSolution import KroghSolution2DCone kroghSol = KroghSolution2DCone(self) self['PO2PlasmaInlet'] = self['PO2RBCInlet'] \ - kroghSol.intravascResistancePO2Drop(0.0)
def compute_PO2Tissue(self): from HbO2.model.kroghSolution import KroghSolution2DCone kroghSol = KroghSolution2DCone(self) self['PO2Tissue'] = kroghSol.averagePO2Tissue()
def __init__(self, simParams): self.kroghSol = KroghSolution2DCone(simParams) self.kroghSol.convO2Transport = False # for faster computation of PO2Wall # self.fig, self.ax = plt.subplots(1) self.nx = 50 self.nM = 50
def __init__(self, simParams): self.simParams = simParams self.kroghSol = KroghSolution2DCone(simParams) self.KRI = 2 * self.kroghSol.intravascResistance()
#!/usr/bin/env python """ Compute Krogh solution at a given location in an axisymmetric region around a capillary. """ import argparse from HbO2.model.kroghSolution import KroghSolution2DCone from HbO2.setup.simulationParameters import IOHbO2ParametersAxisymmetric parser = argparse.ArgumentParser() parser.add_argument('-x', type=float, help='Axial position') parser.add_argument('-r', type=float, help='Radial position') args = parser.parse_args() x = args.x r = args.r sim_params = IOHbO2ParametersAxisymmetric('.') krogh_sol = KroghSolution2DCone(sim_params) print "Saturation at x: {:9.8g}".format(krogh_sol.saturationAtX(x)) print "PO2 at (x, r): {:9.8g}".format(krogh_sol.PO2Tissue(x, r))
def __init__(self, parallel_capillaries, casePath='.'): super(DiffusiveInteractionModelTwoCapillaries, self).__init__(parallel_capillaries) self.simParams = IOHbO2ParametersAxisymmetric(casePath) self.kroghSol = KroghSolution2DCone(self.simParams) self.k_ci = DiffusiveInteractionResistanceAnalytical(self.simParams).k_ci()