Example #1
0
        public void AddModelToSimulation(Model.Simulation simulation)
        {
            _simulationModelCreator.CreateModelFor(simulation);

            simulation.Solver.Parameter(Constants.Parameters.ABS_TOL).Value = CoreConstants.DEFAULT_ABS_TOL;
            simulation.Solver.Parameter(Constants.Parameters.REL_TOL).Value = CoreConstants.DEFAULT_REL_TOL;

            _registrationTask.Register(simulation);
        }
Example #2
0
        private IndividualSimulation createAndRun(Func <ISimulationFactory, IndividualSimulation> individualSimulationCreator)
        {
            var individualSimulation = individualSimulationCreator(_simulationFactory);

            try
            {
                _registrationTask.Register(individualSimulation);
                _simulationEngine.Run(individualSimulation);
            }
            finally
            {
                _registrationTask.Unregister(individualSimulation);
            }

            return(individualSimulation);
        }
Example #3
0
        private void loadObjectBase <T>(T objectToLoad) where T : IObjectBase
        {
            using (var progressUpdater = _progressManager.Create())
            {
                progressUpdater.ReportStatusMessage(PKSimConstants.UI.LoadingObject(objectToLoad.Name));

                //first unregistered the object to load that might contain dummy objects that should be deleted
                _registrationTask.Unregister(objectToLoad);

                //load object content
                _contentLoader.LoadContentFor(objectToLoad);

                _registrationTask.Register(objectToLoad);

                //special loading steps for simulation
                loadSimulations(objectToLoad as Simulation);
            }
        }
Example #4
0
        private void addExpressionProfilesUsedBySimulationSubjectToProject(ISimulationSubject simulationSubject)
        {
            var project = _projectRetriever.Current;

            foreach (var molecule in simulationSubject.AllMolecules())
            {
                var defaultExpressionProfileName = CoreConstants.ContainerName.ExpressionProfileName(molecule.Name, simulationSubject.Species, simulationSubject.Name);

                var expressionProfileName = _containerTask.CreateUniqueName(project.All <ExpressionProfile>(), defaultExpressionProfileName, canUseBaseName: true);
                var expressionProfile     = _expressionProfileFactory.Create(molecule.GetType(), simulationSubject.Species, molecule.Name);

                //Use a unique name in project
                expressionProfile.Name = expressionProfileName;
                _expressionProfileUpdater.SynchronizeExpressionProfileWithSimulationSubject(expressionProfile, simulationSubject);

                //Some parameters are probably marked as FixedValue event thought they have not changed (Formula=>constant) due to change in
                //definition of Fraction expressed basolateral going from a constant to a formula. We reset is fixed value and default state
                expressionProfile.Individual.AllMoleculeParametersFor(expressionProfile.Molecule)
                .Where(x => !x.Visible)
                .Where(x => x.IsFixedValue)
                .Each(x => x.IsFixedValue = false);

                expressionProfile.Individual.AllMoleculeParametersFor(expressionProfile.Molecule)
                .Where(x => !x.Editable)
                .Where(x => !x.IsDefault)
                .Each(x => x.IsDefault = true);

                //only add at the end once the expression profile has been updated
                simulationSubject.AddExpressionProfile(expressionProfile);
                project.AddBuildingBlock(expressionProfile);
                _registrationTask.Register(expressionProfile);
                _eventPublisher.PublishEvent(new BuildingBlockAddedEvent(expressionProfile, _projectRetriever.Current));
            }

            _converted = true;
        }
Example #5
0
 public void Register(IWithId objectToRegister)
 {
     _registrationTask.Register(objectToRegister);
 }