Esempio n. 1
0
        public IParameter CreateFor(ParameterRateMetaData parameterRateDefinition, IFormulaCache formulaCache)
        {
            var param = _objectBaseFactory.CreateParameter();

            param.Formula = _formulaFactory.RateFor(parameterRateDefinition, formulaCache);

            if (!string.IsNullOrEmpty(parameterRateDefinition.RHSRate))
            {
                param.RHSFormula = _formulaFactory.RHSRateFor(parameterRateDefinition, formulaCache);
            }

            setParameterProperties(param, parameterRateDefinition);
            updateDefaultValueFor(param);
            return(param);
        }
Esempio n. 2
0
        private void setStartFormulasForStaticMolecules(IMoleculeStartValuesBuildingBlock defaultStartValues, Simulation simulation, IEnumerable <Compound> compounds)
        {
            var modelName = simulation.ModelConfiguration.ModelName;
            //get the names of molecules that are static (e.g. not enzymes, metabolites, etc.)
            // (e.g. FcRn in 2pores-model)
            var staticMoleculeNames = _modelContainerMoleculeRepository.MoleculeNamesIncludingDrug(modelName);
            var compoundNames       = compounds.AllNames().ToList();

            foreach (var moleculeStartValue in defaultStartValues)
            {
                var dbMoleculeName = getDbMoleculeName(moleculeStartValue.MoleculeName, compoundNames);

                if (staticMoleculeNames.Contains(dbMoleculeName))
                {
                    moleculeStartValue.IsPresent             = _modelContainerMoleculeRepository.IsPresent(modelName, moleculeStartValue.ContainerPath, dbMoleculeName);
                    moleculeStartValue.NegativeValuesAllowed = _modelContainerMoleculeRepository.NegativeValuesAllowed(modelName, moleculeStartValue.ContainerPath, dbMoleculeName);
                }
                else
                {
                    moleculeStartValue.IsPresent             = false;
                    moleculeStartValue.NegativeValuesAllowed = false;
                }

                var moleculeDbPath = moleculeStartValue.ContainerPath.Clone <IObjectPath>();

                moleculeDbPath.Add(dbMoleculeName);

                var rateKey = _moleculeStartFormulaRepository.RateKeyFor(moleculeDbPath, simulation.ModelProperties);

                if (rateKey == null)
                {
                    continue; //no start formula available
                }
                //set molecule start formula
                moleculeStartValue.Formula = _formulaFactory.RateFor(rateKey, defaultStartValues.FormulaCache);
            }
        }