idaes-pse icon indicating copy to clipboard operation
idaes-pse copied to clipboard

ConfigurationError for ControlVolumes regarding time units

Open adam-a-a opened this issue 6 months ago • 3 comments

It appears that the following configuration error in ControlVolume0D (and similarly for 1D) will not be called when time_units is set to None while instantiating a Flowsheet:

if self.config.dynamic:
    f_time_units = self.flowsheet().time_units
    if (f_time_units is None) ^ (units("time") is None):
        raise ConfigurationError(
            "{} incompatible time unit specification between "
            "flowsheet and property package. Either both must use "
            "units, or neither.".format(self.name)
        )

Instead, the ConfigurationError from FlowsheetBlockData will be raised:

elif self.config.time_units is None and self.config.dynamic:
    raise ConfigurationError(
        f"{self.name} - no units were specified for the time domain. "
        f"Units must be be specified for dynamic models."

So it seems the first ConfigurationError that I mentioned will only be raised if time_units are set appropriately and no units are specified for the property model. Notably, there seems to be no testing to ensure the config error occurs.

Additionally, there is no safeguard in the case where the user might provide dimensionless units for the flowsheet and units for the property model. For example, setting time_units to dimensionless for the Flowsheet while using units in the property package will result in a InconsistentUnitsError for material_balances: InconsistentUnitsError: Error in convert: units not compatible.: mole not compatible with mole / second.

adam-a-a avatar Aug 07 '24 18:08 adam-a-a