private void updateInteractionFactor(IContainer processParameterContainer, string moleculeName, IEnumerable <IInteractionKineticUpdaterSpecification> allUpdatingKinetics, IFormulaCache formulaCache, string parameterName, Func <IParameter, string> createFormulaAction) { var interactionFactor = processParameterContainer.Parameter(parameterName); if (!allUpdatingKinetics.Any() || interactionFactor == null) { return; } var formulaName = CoreConstants.CompositeNameFor(processParameterContainer.Name, moleculeName, parameterName); var formula = formulaCache.FindByName(formulaName) as ExplicitFormula; if (formula != null) { interactionFactor.Formula = formula; return; } formula = _objectBaseFactory.Create <ExplicitFormula>() .WithName(formulaName) .WithDimension(interactionFactor.Dimension); interactionFactor.Formula = formula; formula.FormulaString = createFormulaAction(interactionFactor); formulaCache.Add(formula); }
private void updateTransporterFormulaFromCache(ITransportBuilder transportBuilder, IFormulaCache formulaCache) { var formula = transportBuilder.Formula; //only add transporter formula if not already defined in the cache if (formulaCache.ExistsByName(formula.Name)) { transportBuilder.Formula = formulaCache.FindByName(formula.Name); } else { formulaCache.Add(formula); } }
private IFormula insolubleDrugStartFormula(IFormulaCache formulaCache) { if (formulaCache.ExistsByName(CoreConstants.Formula.InsolubleDrugStartFormula)) { return(formulaCache.FindByName(CoreConstants.Formula.InsolubleDrugStartFormula)); } var moleculeStartFormula = _objectBaseFactory.Create <ExplicitFormula>() .WithName(CoreConstants.Formula.InsolubleDrugStartFormula) .WithDimension(_dimensionRepository.Amount) .WithFormulaString("0"); formulaCache.Add(moleculeStartFormula); return(moleculeStartFormula); }
private IFormula drugMassFormula(IFormulaCache formulaCache) { if (formulaCache.ExistsByName(Constants.Parameters.DRUG_MASS)) { return(formulaCache.FindByName(Constants.Parameters.DRUG_MASS)); } var startFormula = _objectBaseFactory.Create <ExplicitFormula>() .WithFormulaString(Constants.Parameters.DRUG_MASS) .WithDimension(_dimensionRepository.Amount) .WithName(Constants.Parameters.DRUG_MASS); var pathToDrugMass = _objectPathFactory.CreateFormulaUsablePathFrom(ObjectPath.PARENT_CONTAINER, CoreConstants.ContainerName.ProtocolSchemaItem, Constants.Parameters.DRUG_MASS) .WithAlias(Constants.Parameters.DRUG_MASS) .WithDimension(_dimensionRepository.Amount); startFormula.AddObjectPath(pathToDrugMass); formulaCache.Add(startFormula); return(startFormula); }
public IFormula ConcentrationFormulaFor(IFormulaCache formulaCache) { if (formulaCache.ExistsByName(Constants.CONCENTRATION_FORMULA)) { return(formulaCache.FindByName(Constants.CONCENTRATION_FORMULA)); } var formula = _objectBaseFactory.Create <ExplicitFormula>() .WithName(Constants.CONCENTRATION_FORMULA) .WithFormulaString("V>0 ? M/V : 0"); formula.AddObjectPath(_objectPathFactory.CreateFormulaUsablePathFrom(ObjectPath.PARENT_CONTAINER) .WithAlias("M") .WithDimension(_dimensionFactory.Dimension(Constants.Dimension.MOLAR_AMOUNT))); formula.AddObjectPath(createVolumeReferencePath(ObjectPath.PARENT_CONTAINER, ObjectPath.PARENT_CONTAINER, Constants.Parameters.VOLUME)); formulaCache.Add(formula); formula.Dimension = _dimensionFactory.Dimension(Constants.Dimension.MOLAR_CONCENTRATION); return(formula); }
private IFormula particleDrugMassFormula(IFormulaCache formulaCache) { if (formulaCache.ExistsByName(CoreConstants.Parameters.PARTICLE_BIN_DRUG_MASS)) { return(formulaCache.FindByName(CoreConstants.Parameters.PARTICLE_BIN_DRUG_MASS)); } var pathToDrugMass = _objectPathFactory.CreateFormulaUsablePathFrom(ObjectPath.PARENT_CONTAINER, CoreConstants.Parameters.PARTICLE_BIN_DRUG_MASS) .WithAlias("ParticleBinDrugMass") .WithDimension(_dimensionRepository.Amount); var startFormula = _objectBaseFactory.Create <ExplicitFormula>() .WithFormulaString(pathToDrugMass.Alias) .WithDimension(_dimensionRepository.Amount) .WithName(CoreConstants.Parameters.PARTICLE_BIN_DRUG_MASS); startFormula.AddObjectPath(pathToDrugMass); formulaCache.Add(startFormula); return(startFormula); }
private static T getFormulaFromCache <T>(IFormulaCache formulaCache, string formulaName) where T : class, IFormula { return(formulaCache.FindByName(formulaName) as T); }