コード例 #1
0
ファイル: case.py プロジェクト: ahmmedshakil/O2RBC
def make_post_processor(case_path, param_file='postprocess.json', **kwargs):
    """
    Factory for a postprocessor. If not given, loads settings in a dictionary to create a postprocessor
    with various features, The settings dictionary can also be given as a kwarg.

    The postprocessor construction is based on the decorator design pattern.

    Args:
        case_path (str): path to case
        param_file (str, optional): name of the file with postprocessing settings
        **settings_dict (dict, optional): dictionary with postprocessing settings

    Returns:
        CasePostProcessor instance
    """
    settings_dict = kwargs.get('settings_dict',
                               load_settings_file(case_path, param_file=param_file))
    if isAxisymmetricCase(case_path):
        postprocessor = CasePostProcessor(case_path)
    else:
        postprocessor = GraphCasePostProcessor(case_path)
    for postproc_dict in settings_dict['postprocessing']:
        postprocessor_class = type_to_postprocessor_class[postproc_dict['type']]
        arg_dict = {key: postproc_dict[key] for key in postproc_dict if key != 'type'}
        postprocessor = postprocessor_class(postprocessor, **arg_dict)
    return postprocessor
コード例 #2
0
ファイル: postprocess.py プロジェクト: ahmmedshakil/O2RBC
    def __init__(self, decorated, **kwargs):
        """
        Constructors

        Args:
            decorated (PostProcessDecorator): decorated object
            **nAverage (int): number of RBCs used for averaging
        """
        super(COSHPostProcessor, self).__init__(decorated)
        if isAxisymmetricCase(self.case_path):
            self.integrator = COSHDiscretePDFIntegrator(self.simParams)
        elif isGraphCase(self.case_path):
            self.integrator = COSHUniformPDFIntegrator(self.simParams)
        self.nAverage = kwargs['nAverage']
        self.geometry = self.simParams.geometry()
        self.xValues = np.linspace(0, self.geometry['domainLength'], 101)
        try:
            sampledSetDict = loadSampledSets(self.case_path, self.sampledDirName,
                                             self.sampledSetFile,
                                             maxTimeInterval=self.oscillationTimeWindow())
            self.sampledSetStats = sampledsets.SampledSetStatistics(sampledSetDict)
        except IOError:
            warnings.warn("Could not create sampledSetStats.", UserWarning)
            self.sampledSetStats = None

        self.ivrFitter = IntravascularResistanceFitter()

        self.xSampled = 0.5*self.geometry['domainLength']  # position where the radial profiles are sampled
        self.oscillationAmplitude = 1.0  # amplitude for the oscillation radius
        self.relOscillationAmplitude = 0.02  # rel. amplitude for the rel. oscill. rad.

        self.SIntegrated = None  # used to cache integration results
        self.optimBoundsKRI = [1e5, 1e9]
コード例 #3
0
ファイル: case.py プロジェクト: ahmmedshakil/O2RBC
    def sValues(self):
        """
        Return the curvilinear coordinates to use on the edge.

        For simulations in graphs, an offset might need to be added to self.xValues.
        """
        if isAxisymmetricCase(self.case_path):
            return self.xValues
        elif isGraphStraightCapillariesCase(self.case_path):
            return self.xValues + self.simParams.sCoordOffset()
        else:
            raise RuntimeError('Case type not supported')
コード例 #4
0
 def make_sim_params(self, case_path, use_numerics=False):
     if isAxisymmetricCase(case_path):
         if use_numerics:
             return IOHbO2SimulationParametersAxisymmetric(case_path)
         else:
             return IOHbO2ParametersAxisymmetric(case_path)
     elif isGraphCase(case_path):
         if isGraphStraightCapillariesCase(case_path):
             if use_numerics:
                 return IOHbO2SimulationParametersStraightCapillaries(
                     case_path)
             else:
                 return IOHbO2ParametersStraightCapillaries(case_path)
         else:
             if use_numerics:
                 return IOHbO2SimulationParametersGraph(case_path)
             else:
                 return IOHbO2ParametersGraph(case_path)
コード例 #5
0
ファイル: data.py プロジェクト: ahmmedshakil/O2RBC
def make_rbc_data(case_path):
    """
    Factory for RBC data.

    Args:
        case_path (str): path to case

    Returns:
        RBCData instance
    """
    if isGraphCase(case_path):
        if isGraphStraightCapillariesCase(case_path):
            return RBCDataGraphStraightCapillaries(case_path)
        else:
            return RBCDataGraph(case_path)
    elif isAxisymmetricCase(case_path):
        if os.path.exists(os.path.join(case_path, 'domain',
                                       'RBCPositions.txt')):
            return RBCDataAxisymmetricLegacy(case_path)
        else:
            return RBCDataAxisymmetric(case_path)
コード例 #6
0
def plotHbSimulatedAndAnalytical(caseName, simParams, **kwargs):
    if isGraphCase(caseName):
        plotHbSimulatedGraph(caseName)
    elif isAxisymmetricCase(caseName):
        plotHbSimulatedAxisymmetric(caseName)
    plotHbProfile(simParams, **kwargs)
コード例 #7
0
ファイル: case.py プロジェクト: ahmmedshakil/O2RBC
 def rbcDataPostProcessor(self):
     if isGraphCase(self.case_path):
         return RBCDataGraphPostProcessor(self.rbc_data)
     elif isAxisymmetricCase(self.case_path):
         return RBCDataPostProcessor(self.rbc_data)
コード例 #8
0
        IOHbO2ParametersStraightCapillaries.dependentVariables)
    # no dependent variables are defined in HbO2SimulationParameters
    dependentVariables['CFL'] = ['deltaT']
    dependentVariables['dx'] = ['deltaT']
    dependentVariables['RBCVelocity'] = ['deltaT']

    def __init__(self, case_path='.'):
        super(IOHbO2SimulationParametersStraightCapillaries,
              self).__init__(case_path)


if __name__ == "__main__":
    from HbO2.setup.case import SimulationParametersFactory
    simParams = SimulationParametersFactory().make_sim_params(
        '.', use_numerics=True)
    if isAxisymmetricCase('.'):
        print "Computed deltaT: %g" % simParams['deltaT']
        print simParams
        print "RBC length after setting the radiusRBC to radiusPlasma:"
        simParams['radiusRBC'] = simParams['radiusPlasma']
        print simParams['RBCLength'], simParams['RBCHalfLength']
        print "RBC length after increasing RBC volume:"
        simParams['RBCVolume'] = 69e-18
        print simParams['RBCLength'], simParams['RBCHalfLength']
        simParams.update_files()
    elif isGraphCase('.'):
        print "Computed PO2Tissue: {:g}".format(simParams['PO2Tissue'])
        print "Computed HbInit: {:g}".format(simParams['HbInit'])
        print "Computed deltaT: {:g}".format(simParams['deltaT'])
        simParams.update_files()