Exemple #1
0
    def runSimulations(self):
        self.setPhase(0, "Running simulations...", indeterminate=False)

        self.setAnalysisModule()

        active_realization_mask = ActiveRealizationsModel().getActiveRealizationsMask()

        if self.ert().getEnkfSimulationRunner().isHookPreSimulation():
            self.ert().getEnkfSimulationRunner().runHookWorkflow()

        success = self.ert().getEnkfSimulationRunner().runSimpleStep(active_realization_mask, EnkfInitModeEnum.INIT_CONDITIONAL , 0)

        if not success:
            min_realization_count = self.ert().analysisConfig().getMinRealisations()
            success_count = active_realization_mask.count()

            if min_realization_count > success_count:
                raise ErtRunError("Simulation failed! Number of successful realizations less than MIN_REALIZATIONS %d < %d" % (success_count, min_realization_count))
            elif success_count == 0:
                raise ErtRunError("Simulation failed! All realizations failed!")
            #else ignore and continue


        if self.ert().getEnkfSimulationRunner().isHookPostSimulation():
            self.ert().getEnkfSimulationRunner().runHookWorkflow()

        self.setPhaseName("Post processing...", indeterminate=True)
        self.ert().getEnkfSimulationRunner().runPostHookWorkflow()

        self.setPhaseName("Analyzing...", indeterminate=True)

        target_case_name = TargetCaseModel().getValue()
        target_fs = self.ert().getEnkfFsManager().getFileSystem(target_case_name)

        success = self.ert().getEnkfSimulationRunner().smootherUpdate(target_fs)

        if not success:
            raise ErtRunError("Analysis of simulation failed!")

        self.setPhase(1, "Running simulations...", indeterminate=False)

        self.ert().getEnkfFsManager().switchFileSystem(target_fs)
        success = self.ert().getEnkfSimulationRunner().runSimpleStep(active_realization_mask, EnkfInitModeEnum.INIT_NONE, 1)

        if not success:
            raise ErtRunError("Simulation failed!")

        self.setPhaseName("Post processing...", indeterminate=True)

        if self.ert().getEnkfSimulationRunner().isHookPostSimulation():
            self.ert().getEnkfSimulationRunner().runHookWorkflow()

        # Special QC workflow for backward compatibility
        self.ert().getEnkfSimulationRunner().runPostHookWorkflow()

        self.setPhase(2, "Simulations completed.")
Exemple #2
0
    def runSimulations(self):
        self.setPhase(0, "Running simulations...", indeterminate=False)
        self.setAnalysisModule()
        active_realization_mask = ActiveRealizationsModel().getActiveRealizationsMask()

        self.setPhaseName("Pre processing...", indeterminate=True)
        self.ert().getEnkfSimulationRunner().createRunPath(active_realization_mask, 0)
        self.ert().getEnkfSimulationRunner().runWorkflows( HookRuntime.PRE_SIMULATION )

        self.setPhaseName("Running forecast...", indeterminate=False)
        success = self.ert().getEnkfSimulationRunner().runSimpleStep(active_realization_mask, EnkfInitModeEnum.INIT_CONDITIONAL , 0)

        if not success:
            min_realization_count = self.ert().analysisConfig().getMinRealisations()
            success_count = active_realization_mask.count()

            if min_realization_count > success_count:
                raise ErtRunError("Simulation failed! Number of successful realizations less than MIN_REALIZATIONS %d < %d" % (success_count, min_realization_count))
            elif success_count == 0:
                raise ErtRunError("Simulation failed! All realizations failed!")
            #else ignore and continue



        self.setPhaseName("Post processing...", indeterminate=True)
        self.ert().getEnkfSimulationRunner().runWorkflows( HookRuntime.POST_SIMULATION )

        self.setPhaseName("Analyzing...")

        target_case_name = TargetCaseModel().getValue()
        target_fs = self.ert().getEnkfFsManager().getFileSystem(target_case_name)
        source_fs = self.ert().getEnkfFsManager().getCurrentFileSystem()
        
        es_update = self.ert().getESUpdate( ) 
        success = es_update.smootherUpdate(source_fs, target_fs)
        if not success:
            raise ErtRunError("Analysis of simulation failed!")

        self.setPhase(1, "Running simulations...")
        self.ert().getEnkfFsManager().switchFileSystem(target_fs)
        
        self.setPhaseName("Pre processing...")
        self.ert().getEnkfSimulationRunner().createRunPath(active_realization_mask, 1)
        self.ert().getEnkfSimulationRunner().runWorkflows( HookRuntime.PRE_SIMULATION )

        self.setPhaseName("Running forecast...", indeterminate=False)

        success = self.ert().getEnkfSimulationRunner().runSimpleStep(active_realization_mask, EnkfInitModeEnum.INIT_NONE, 1)

        if not success:
            raise ErtRunError("Simulation failed!")

        self.setPhaseName("Post processing...", indeterminate=True)
        self.ert().getEnkfSimulationRunner().runWorkflows( HookRuntime.POST_SIMULATION )

        self.setPhase(2, "Simulations completed.")
    def __init__(self):
        SimulationConfigPanel.__init__(self, EnsembleExperiment())

        layout = QFormLayout()

        case_model = CaseSelectorModel()
        case_selector = ComboChoice(case_model, "Current case", "init/current_case_selection")
        layout.addRow(case_selector.getLabel(), case_selector)

        runpath_model = RunPathModel()
        runpath_label = ActiveLabel(runpath_model, "Runpath", "config/simulation/runpath")
        layout.addRow(runpath_label.getLabel(), runpath_label)


        number_of_realizations_model = EnsembleSizeModel()
        number_of_realizations_label = ActiveLabel(number_of_realizations_model, "Number of realizations", "config/ensemble/num_realizations")
        layout.addRow(number_of_realizations_label.getLabel(), number_of_realizations_label)

        active_realizations_model = ActiveRealizationsModel()
        self.active_realizations_field = StringBox(active_realizations_model, "Active realizations", "config/simulation/active_realizations")
        self.active_realizations_field.setValidator(RangeStringArgument(number_of_realizations_model.getValue()))
        layout.addRow(self.active_realizations_field.getLabel(), self.active_realizations_field)

        self.active_realizations_field.validationChanged.connect(self.simulationConfigurationChanged)


        self.setLayout(layout)
Exemple #4
0
    def runSimulations(self):
        self.setPhase(0, "Running simulations...", indeterminate=False)
        active_realization_mask = ActiveRealizationsModel(
        ).getActiveRealizationsMask()

        self.setPhaseName("Pre processing...", indeterminate=True)
        self.ert().getEnkfSimulationRunner().createRunPath(
            active_realization_mask, 0)
        self.ert().getEnkfSimulationRunner().runWorkflows(
            HookRuntime.PRE_SIMULATION)

        self.setPhaseName("Running ensemble experiment...",
                          indeterminate=False)

        success = self.ert().getEnkfSimulationRunner().runEnsembleExperiment(
            active_realization_mask)

        if not success:
            raise ErtRunError("Simulation failed!")

        self.setPhaseName("Post processing...", indeterminate=True)
        self.ert().getEnkfSimulationRunner().runWorkflows(
            HookRuntime.POST_SIMULATION)

        self.setPhase(1, "Simulations completed.")  # done...
    def __init__(self):
        '''
        Fills in the input panel for sensitivity study parameters.
        '''

        SimulationConfigPanel.__init__(self, SensitivityStudy())

        layout = QFormLayout()

        case_model = CaseSelectorModel()
        case_selector = ComboChoice(case_model, "Current case",
                                    "init/current_case_selection")
        layout.addRow(case_selector.getLabel(), case_selector)

        runpath_model = RunPathModel()
        runpath_label = ActiveLabel(runpath_model, "Runpath",
                                    "config/simulation/runpath")
        layout.addRow(runpath_label.getLabel(), runpath_label)

        number_of_realizations_model = EnsembleSizeModel()
        number_of_realizations_label = ActiveLabel(
            number_of_realizations_model, "Number of realizations",
            "config/ensemble/num_realizations")
        layout.addRow(number_of_realizations_label.getLabel(),
                      number_of_realizations_label)

        sensitivity_target_case_format_model = SensitivityTargetCaseFormatModel(
        )
        self.iterated_target_case_format_field = StringBox(
            sensitivity_target_case_format_model, "Target case format",
            "config/simulation/sensitivity_target_case_format")
        self.iterated_target_case_format_field.setValidator(
            ProperNameFormatStringArgument())
        layout.addRow(self.iterated_target_case_format_field.getLabel(),
                      self.iterated_target_case_format_field)

        self.parameters_popup_button = QToolButton()
        self.parameters_popup_button.setIcon(
            util.resourceIcon("ide/small/cog_edit.png"))
        self.parameters_popup_button.clicked.connect(self.showParametersPopup)
        self.parameters_popup_button.setMaximumSize(20, 20)

        layout.addRow("Parameters:", self.parameters_popup_button)

        active_realizations_model = ActiveRealizationsModel()
        self.active_realizations_field = StringBox(
            active_realizations_model, "Active realizations",
            "config/simulation/active_realizations")
        self.active_realizations_field.setValidator(
            RangeStringArgument(number_of_realizations_model.getValue()))
        layout.addRow(self.active_realizations_field.getLabel(),
                      self.active_realizations_field)

        self.active_realizations_field.validationChanged.connect(
            self.simulationConfigurationChanged)

        self.setLayout(layout)
    def runSimulations(self):
        self.setPhase(0, "Running simulations...", indeterminate=False)
        active_realization_mask = ActiveRealizationsModel().getActiveRealizationsMask()
        success = self.ert().getEnkfSimulationRunner().runEnsembleExperiment(active_realization_mask)

        if not success:
            raise ErtRunError("Simulation failed!")

        self.setPhaseName("Post processing...", indeterminate=True)
        self.ert().getEnkfSimulationRunner().runPostWorkflow()

        self.setPhase(1, "Simulations completed.") # done...
Exemple #7
0
    def runSimulations(self):
        phase_count = NumberOfIterationsModel().getValue() + 1
        self.setPhaseCount(phase_count)

        analysis_module = self.setAnalysisModule()
        active_realization_mask = ActiveRealizationsModel().getActiveRealizationsMask()

        source_fs = self.ert().getEnkfFsManager().getCurrentFileSystem()
        initial_fs = self.createTargetCaseFileSystem(0)

        if not source_fs == initial_fs:
            self.ert().getEnkfFsManager().switchFileSystem(initial_fs)
            self.ert().getEnkfFsManager().initializeCurrentCaseFromExisting(source_fs, 0)

        self.runAndPostProcess(active_realization_mask, 0, phase_count, EnkfInitModeEnum.INIT_CONDITIONAL)
        target_case_format = TargetCaseFormatModel().getValue()
        self.ert().analysisConfig().getAnalysisIterConfig().setCaseFormat( target_case_format )

        analysis_config = self.ert().analysisConfig()
        analysis_iter_config = analysis_config.getAnalysisIterConfig()
        num_retries_per_iteration = analysis_iter_config.getNumRetries()
        num_tries = 0
        current_iteration = 1

        while current_iteration <= NumberOfIterationsModel().getValue() and num_tries < num_retries_per_iteration:
            target_fs = self.createTargetCaseFileSystem(current_iteration)

            pre_analysis_iter_num = analysis_module.getInt("ITER")
            self.analyzeStep(target_fs)
            post_analysis_iter_num = analysis_module.getInt("ITER")

            analysis_success = False
            if  post_analysis_iter_num > pre_analysis_iter_num:
                analysis_success = True

            if analysis_success:
                self.ert().getEnkfFsManager().switchFileSystem(target_fs)
                self.runAndPostProcess(active_realization_mask, current_iteration, phase_count, EnkfInitModeEnum.INIT_NONE)
                num_tries = 0
                current_iteration += 1
            else:
                self.ert().getEnkfFsManager().initializeCurrentCaseFromExisting(target_fs, 0)
                self.runAndPostProcess(active_realization_mask, current_iteration - 1 , phase_count, EnkfInitModeEnum.INIT_NONE)
                num_tries += 1



        if current_iteration == phase_count:
            self.setPhase(phase_count, "Simulations completed.")
        else:
            raise ErtRunError("Iterated Ensemble Smoother stopped: maximum number of iteration retries (%d retries) reached for iteration %d" % (num_retries_per_iteration, current_iteration))
    def __init__(self):
        SimulationConfigPanel.__init__(self, IteratedEnsembleSmoother())

        layout = QFormLayout()

        case_model = CaseSelectorModel()
        case_selector = ComboChoice(case_model, "Current case",
                                    "init/current_case_selection")
        layout.addRow(case_selector.getLabel(), case_selector)

        run_path_model = RunPathModel()
        run_path_label = ActiveLabel(run_path_model, "Runpath",
                                     "config/simulation/runpath")
        layout.addRow(run_path_label.getLabel(), run_path_label)

        number_of_realizations_model = EnsembleSizeModel()
        number_of_realizations_label = ActiveLabel(
            number_of_realizations_model, "Number of realizations",
            "config/ensemble/num_realizations")
        layout.addRow(number_of_realizations_label.getLabel(),
                      number_of_realizations_label)

        num_iterations_model = NumberOfIterationsModel()
        num_iterations_spinner = IntegerSpinner(
            num_iterations_model, "Number of iterations",
            "config/simulation/number_of_iterations")
        layout.addRow(num_iterations_spinner.getLabel(),
                      num_iterations_spinner)

        iterated_target_case_format_model = TargetCaseFormatModel()
        self.iterated_target_case_format_field = StringBox(
            iterated_target_case_format_model, "Target case format",
            "config/simulation/iterated_target_case_format")
        self.iterated_target_case_format_field.setValidator(
            ProperNameFormatArgument())
        layout.addRow(self.iterated_target_case_format_field.getLabel(),
                      self.iterated_target_case_format_field)

        iterated_analysis_module_model = IteratedAnalysisModuleModel()
        self.iterated_analysis_module_choice = ComboChoice(
            iterated_analysis_module_model, "Analysis Module",
            "config/analysis/iterated_analysis_module")

        self.variables_popup_button = QToolButton()
        self.variables_popup_button.setIcon(
            util.resourceIcon("ide/small/cog_edit.png"))
        self.variables_popup_button.clicked.connect(self.showVariablesPopup)
        self.variables_popup_button.setMaximumSize(20, 20)

        self.variables_layout = QHBoxLayout()
        self.variables_layout.addWidget(self.iterated_analysis_module_choice,
                                        0, Qt.AlignLeft)
        self.variables_layout.addWidget(self.variables_popup_button, 0,
                                        Qt.AlignLeft)
        self.variables_layout.setContentsMargins(QMargins(0, 0, 0, 0))
        self.variables_layout.addStretch()

        layout.addRow(self.iterated_analysis_module_choice.getLabel(),
                      self.variables_layout)

        active_realizations_model = ActiveRealizationsModel()
        self.active_realizations_field = StringBox(
            active_realizations_model, "Active realizations",
            "config/simulation/active_realizations")
        self.active_realizations_field.setValidator(RangeStringArgument())
        layout.addRow(self.active_realizations_field.getLabel(),
                      self.active_realizations_field)

        self.iterated_target_case_format_field.validationChanged.connect(
            self.simulationConfigurationChanged)
        self.active_realizations_field.validationChanged.connect(
            self.simulationConfigurationChanged)

        self.setLayout(layout)
Exemple #9
0
    def runSimulations(self):
        self.setPhase(0, "Running simulations...", indeterminate=False)
        self.setAnalysisModule()
        active_realization_mask = ActiveRealizationsModel(
        ).getActiveRealizationsMask()

        self.setPhaseName("Pre processing...", indeterminate=True)
        self.ert().getEnkfSimulationRunner().createRunPath(
            active_realization_mask, 0)
        self.ert().getEnkfSimulationRunner().runWorkflows(
            HookRuntime.PRE_SIMULATION)

        self.setPhaseName("Running forecast...", indeterminate=False)
        success = self.ert().getEnkfSimulationRunner().runSimpleStep(
            active_realization_mask, EnkfInitModeEnum.INIT_CONDITIONAL, 0)

        if not success:
            min_realization_count = self.ert().analysisConfig(
            ).getMinRealisations()
            success_count = active_realization_mask.count()

            if min_realization_count > success_count:
                raise ErtRunError(
                    "Simulation failed! Number of successful realizations less than MIN_REALIZATIONS %d < %d"
                    % (success_count, min_realization_count))
            elif success_count == 0:
                raise ErtRunError(
                    "Simulation failed! All realizations failed!")
            #else ignore and continue

        self.setPhaseName("Post processing...", indeterminate=True)
        self.ert().getEnkfSimulationRunner().runWorkflows(
            HookRuntime.POST_SIMULATION)

        self.setPhaseName("Analyzing...", indeterminate=True)

        target_case_name = TargetCaseModel().getValue()
        target_fs = self.ert().getEnkfFsManager().getFileSystem(
            target_case_name)
        source_fs = self.ert().getEnkfFsManager().getCurrentFileSystem()
        success = self.ert().getEnkfSimulationRunner().smootherUpdate(
            source_fs, target_fs)

        if not success:
            raise ErtRunError("Analysis of simulation failed!")

        self.setPhase(1, "Running simulations...", indeterminate=False)
        self.ert().getEnkfFsManager().switchFileSystem(target_fs)

        self.setPhaseName("Pre processing...", indeterminate=True)
        self.ert().getEnkfSimulationRunner().createRunPath(
            active_realization_mask, 1)
        self.ert().getEnkfSimulationRunner().runWorkflows(
            HookRuntime.PRE_SIMULATION)

        self.setPhaseName("Running forecast...", indeterminate=True)

        success = self.ert().getEnkfSimulationRunner().runSimpleStep(
            active_realization_mask, EnkfInitModeEnum.INIT_NONE, 1)

        if not success:
            raise ErtRunError("Simulation failed!")

        self.setPhaseName("Post processing...", indeterminate=True)
        self.ert().getEnkfSimulationRunner().runWorkflows(
            HookRuntime.POST_SIMULATION)

        self.setPhase(2, "Simulations completed.")