def _property_check(self, key, property, local_error, global_error=None):
        """Generic property check for a chemical

        Parameters
        ----------
        key : str
            Identifier of role to check
        property: HasTraits
            Property of chemical to check
        local_error: str
            Local error message to raise if check fails
        global_error: str (optional)
            Global error message to raise if check fails

        Returns
        -------
        errors: list(VerifierError)
            List of errors raised by check
        """
        errors = []
        if self.role == key and property < 0:
            errors.append(
                VerifierError(
                    subject=self,
                    local_error=local_error,
                    global_error=global_error,
                ))

        return errors
 def setUp(self):
     self.view = DummyBaseMCOOptionsView()
     self.verifier_error = VerifierError(
         subject=self.view,
         local_error="an error",
         global_error="AN ERROR",
         severity="error",
     )
     self.message_list = []
     self.send_to_parent = []
    def _n_chemicals_check(self):
        """ Makes sure there is at least 4 chemicals in the PU blend"""

        if self.n_chemicals < 4:
            return [
                VerifierError(
                    subject=self,
                    local_error="Number of Chemicals must be at least 4",
                    global_error="The Ingredients pre-processor does not "
                    "have enough Chemicals defined",
                )
            ]
        return []
예제 #4
0
    def _n_outputs_check(self):
        """Makes sure there is at least 1 output file in
        the DataSource"""

        errors = []
        if self.n_outputs < 1:
            errors.append(
                VerifierError(subject=self,
                              local_error="Number of output files must"
                              " be at least 1",
                              global_error="An SimPUFoamDataSource does not "
                              "have enough output files defined"))

        return errors
예제 #5
0
    def _n_commands_check(self):
        """Makes sure there is at least 1 executable in
        the DataSource"""

        errors = []
        if self.n_commands < 1:
            errors.append(
                VerifierError(subject=self,
                              local_error="Number of generators/solvers must"
                              " be at least 1",
                              global_error="An SimPUFoamDataSource does not "
                              "have enough generators/solvers defined"))

        return errors
    def _n_fragments_check(self):
        """Makes sure there is at least 1 molecular fragment in
        the Ingredient"""

        errors = []
        if self.n_fragments < 1:
            errors.append(
                VerifierError(subject=self,
                              local_error="Number of molecular fragments must"
                              " be at least 1",
                              global_error="An IngredientDataSource does not "
                              "have enough molecular fragments defined"))

        return errors
    def _n_molecule_types_check(self):
        """Makes sure there is at least 1 Molecule type in the
        Simulation"""

        errors = []
        if self.n_molecule_types < 1:
            errors.append(
                VerifierError(
                    subject=self,
                    local_error="Number of molecule types must"
                    " be at least 1",
                    global_error="A SimulationDataSourceModel does not "
                    "have enough molecular types defined"))

        return errors
    def verify(self):
        """Overloads parent method to include check for initial PUFoam
        volume fraction
        """
        errors = super(PUFoamModel, self).verify()

        if self.foam_volume < 0 or self.foam_volume > 1:
            errors.append(
                VerifierError(
                    subject=self,
                    severity='warning',
                    local_error="PuFoam initial volume is not a fraction",
                    global_error=(
                        "PUFoam initial volume must be between 0 - 1"),
                ))

        return errors