diff --git a/.github/actions/run-examples/examples_for_idaes_ci.py b/.github/actions/run-examples/examples_for_idaes_ci.py index fd38361269..592f495a18 100644 --- a/.github/actions/run-examples/examples_for_idaes_ci.py +++ b/.github/actions/run-examples/examples_for_idaes_ci.py @@ -1,6 +1,7 @@ """ pytest plugin for testing IDAES "through" IDAES/examples within the IDAES/idaes-pse CI """ + from contextlib import contextmanager from dataclasses import dataclass, field import fnmatch diff --git a/.github/workflows/typos.toml b/.github/workflows/typos.toml index 13bcee5705..c0633eb4d3 100644 --- a/.github/workflows/typos.toml +++ b/.github/workflows/typos.toml @@ -38,3 +38,10 @@ astroid = "astroid" delt = "delt" # TEMPORARY - Remove after example update upadate = "upadate" + +# false positive from 1.20.3 +RTO = "RTO" +PN = "PN" +hd = "hd" +Tge = "Tge" +iy = "iy" \ No newline at end of file diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 26de562139..9a043b6f09 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,6 +1,6 @@ repos: - repo: https://github.com/psf/black - rev: 22.3.0 + rev: 24.3.0 hooks: - id: black language_version: python3 diff --git a/.pylint/idaes_transform.py b/.pylint/idaes_transform.py index 9d1e05b5c5..0af6e42de6 100644 --- a/.pylint/idaes_transform.py +++ b/.pylint/idaes_transform.py @@ -4,6 +4,7 @@ See #1159 for more information. """ + from dataclasses import dataclass import sys import functools diff --git a/docs/explanations/components/ui/index.rst b/docs/explanations/components/ui/index.rst index 36a62674c8..e4c27e17e4 100644 --- a/docs/explanations/components/ui/index.rst +++ b/docs/explanations/components/ui/index.rst @@ -4,7 +4,7 @@ User Interfaces There are several types of user interfaces in IDAES. To learn more about them, follow the links below. -* Graphical user interfaces: see `Flowsheet Visualizer `_ +* Graphical user interfaces: see `Flowsheet Visualizer `_ * `Jupyter Notebooks `_: see `IDAES Examples `_ * Python Application Programming Interfaces (APIs): see :ref:`API Reference` diff --git a/docs/index.rst b/docs/index.rst index 52bc8ccad8..e71f019a40 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -67,7 +67,7 @@ Contents | :doc:`Logging Processing & Outputs ` | :doc:`Developing for IDAES ` | :doc:`Grid integration application ` - | :external+ui:doc:`Flowsheet Visualizer ` + | `Flowsheet Visualizer `_ .. toctree:: :hidden: diff --git a/docs/reference_guides/model_libraries/generic/costing/process_costing_sslw.rst b/docs/reference_guides/model_libraries/generic/costing/process_costing_sslw.rst index a604948398..cbee254cb2 100644 --- a/docs/reference_guides/model_libraries/generic/costing/process_costing_sslw.rst +++ b/docs/reference_guides/model_libraries/generic/costing/process_costing_sslw.rst @@ -138,7 +138,7 @@ Heat Exchanger Cost .. note:: IDAES does not yet support costing for heat exchangers requiring both shell and tube area (HX1D). -The purchse cost is computed based on the base unit cost and three correction factors (Eq. 22.43 in Seider et al.), and is adjusted by user-defined currency units with the appropriate CE index value. The base cost is computed depending on the heat exchanger type selected by the user. +The purchase cost is computed based on the base unit cost and three correction factors (Eq. 22.43 in Seider et al.), and is adjusted by user-defined currency units with the appropriate CE index value. The base cost is computed depending on the heat exchanger type selected by the user. The heat exchanger costing method has three arguments, hx_type = heat exchanger type, material_type = construction material, and tube_length = tube length ('*' corresponds to the default options): diff --git a/docs/reference_guides/model_libraries/generic/property_models/activity_coefficient.rst b/docs/reference_guides/model_libraries/generic/property_models/activity_coefficient.rst index 9536d6fe29..c920e6d588 100644 --- a/docs/reference_guides/model_libraries/generic/property_models/activity_coefficient.rst +++ b/docs/reference_guides/model_libraries/generic/property_models/activity_coefficient.rst @@ -28,7 +28,7 @@ Option 1 - "FTPz":
  • Total molar flow rate (mol/s) - flow_mol
  • Temperature (K) - temperature -
  • Presure (Pa) - pressure +
  • Pressure (Pa) - pressure
  • Mole fraction of the mixture - mole_frac_comp
@@ -43,7 +43,7 @@ Option 2 - "FcTP":
  • Component molar flow rate (mol/s) - flow_mol_comp
  • Temperature (K) - temperature -
  • Presure (Pa) - pressure +
  • Pressure (Pa) - pressure
diff --git a/docs/reference_guides/model_libraries/generic/property_models/ceos.rst b/docs/reference_guides/model_libraries/generic/property_models/ceos.rst index 8e0c201e97..697a500895 100644 --- a/docs/reference_guides/model_libraries/generic/property_models/ceos.rst +++ b/docs/reference_guides/model_libraries/generic/property_models/ceos.rst @@ -183,7 +183,7 @@ List of Variables "``fug_phase_comp``", "Fugacity indexed by phase and component", "Pa" "``fug_coeff_phase_comp``", "Fugacity coefficient indexed by phase and component", "None" "``gibbs_mol_phase``", "Molar Gibbs energy indexed by phase", "J/mol" - "``heat_capacity_ratio_phase``", "Heat capcity ratio by phase", "-" + "``heat_capacity_ratio_phase``", "Heat capacity ratio by phase", "-" "``isothermal_speed_sound_phase``", "Isothermal speed of sound by phase", "m/s" "``isentropic_speed_sound_phase``", "Isentropic speed of sound by phase", "m/s" "``mw``", "Molecular weight of mixture", "kg/mol" diff --git a/docs/reference_guides/model_libraries/power_generation/costing/power_plant_costing_netl.rst b/docs/reference_guides/model_libraries/power_generation/costing/power_plant_costing_netl.rst index 84b10bb27f..2286b292df 100644 --- a/docs/reference_guides/model_libraries/power_generation/costing/power_plant_costing_netl.rst +++ b/docs/reference_guides/model_libraries/power_generation/costing/power_plant_costing_netl.rst @@ -300,7 +300,7 @@ The function has has five arguments, self, equipment, scaled_param, temp_C, and * self : an existing unit model or Pyomo Block * equipment : The type of equipment to be costed, see table 6 * scaled_param : The Pyomo Variable representing the component's scaled parameter -* temp_C : The Pyomo Variable representing the hottest temperature of the piece of equiment being costed. Some pieces of equipment do not have a temperature associated with them, so the default argument is None. This variable must have units of Celsius (Pyomo label `pyunits.C`). +* temp_C : The Pyomo Variable representing the hottest temperature of the piece of equipment being costed. Some pieces of equipment do not have a temperature associated with them, so the default argument is None. This variable must have units of Celsius (Pyomo label `pyunits.C`). * n_equip : The number of pieces of equipment to be costed. The function will evenly divide the scaled parameter between the number passed. * CE_index_year : Chemical Engineering Cost Index base year, defaults to 2018; calling the registered Pyomo currency units dictionary of plant cost index values will allow conversion between base years within the flowsheet * custom_accounts : Additional accounts to cost diff --git a/idaes/apps/grid_integration/bidder.py b/idaes/apps/grid_integration/bidder.py index c1843cc458..ef40720c1e 100644 --- a/idaes/apps/grid_integration/bidder.py +++ b/idaes/apps/grid_integration/bidder.py @@ -25,14 +25,12 @@ class AbstractBidder(ABC): - """ The abstract class for all the bidder and self-schedulers. """ @abstractmethod def update_day_ahead_model(self, **kwargs): - """ Update the day-ahead model (advance timesteps) with necessary parameters in kwargs. @@ -45,7 +43,6 @@ def update_day_ahead_model(self, **kwargs): @abstractmethod def update_real_time_model(self, **kwargs): - """ Update the real-time model (advance timesteps) with necessary parameters in kwargs. @@ -58,7 +55,6 @@ def update_real_time_model(self, **kwargs): @abstractmethod def compute_day_ahead_bids(self, date, hour, **kwargs): - """ Solve the model to bid/self-schedule into the day-ahead market. After solving, record the schedule from the solve. @@ -77,7 +73,6 @@ def compute_day_ahead_bids(self, date, hour, **kwargs): @abstractmethod def compute_real_time_bids(self, date, hour, **kwargs): - """ Solve the model to bid/self-schedule into the real-time market. After solving, record the schedule from the solve. @@ -96,7 +91,6 @@ def compute_real_time_bids(self, date, hour, **kwargs): @abstractmethod def write_results(self, path): - """ This methods writes the saved results into an csv file. @@ -109,7 +103,6 @@ def write_results(self, path): @abstractmethod def formulate_DA_bidding_problem(self): - """ Formulate the day-ahead bidding optimization problem by adding necessary parameters, constraints, and objective function. @@ -123,7 +116,6 @@ def formulate_DA_bidding_problem(self): @abstractmethod def formulate_RT_bidding_problem(self): - """ Formulate the real-time bidding optimization problem by adding necessary parameters, constraints, and objective function. @@ -137,7 +129,6 @@ def formulate_RT_bidding_problem(self): @abstractmethod def record_bids(self, bids, model, date, hour): - """ This function records the bids (schedule) and the details in the underlying bidding model. @@ -162,7 +153,6 @@ def generator(self): return "AbstractGenerator" def _check_inputs(self): - """ Check if the inputs to construct the tracker is valid. If not raise errors. """ @@ -172,7 +162,6 @@ def _check_inputs(self): self._check_solver() def _check_bidding_model_object(self): - """ Check if tracking model object has the necessary methods and attributes. """ @@ -198,7 +187,6 @@ def _check_bidding_model_object(self): ) def _check_n_scenario(self): - """ Check if the number of LMP scenarios is an integer and greater than 0. """ @@ -215,7 +203,6 @@ def _check_n_scenario(self): ) def _check_solver(self): - """ Check if provides solver is a valid Pyomo solver object. """ @@ -227,7 +214,6 @@ def _check_solver(self): class StochasticProgramBidder(AbstractBidder): - """ Template class for bidders that use scenario-based stochastic programs. """ @@ -242,7 +228,6 @@ def __init__( forecaster, real_time_underbid_penalty, ): - """ Initializes the stochastic bidder object. @@ -313,7 +298,6 @@ def _set_up_bidding_problem(self, horizon): return model def formulate_DA_bidding_problem(self): - """ Set up the day-ahead stochastic programming bidding problems. @@ -332,7 +316,6 @@ def formulate_DA_bidding_problem(self): return model def formulate_RT_bidding_problem(self): - """ Set up the real-time stochastic programming bidding problems. @@ -351,7 +334,6 @@ def formulate_RT_bidding_problem(self): return model def _save_power_outputs(self, model): - """ Create references of the power output variable in each price scenario block. @@ -373,7 +355,6 @@ def _save_power_outputs(self, model): return def _add_bidding_params(self, model): - """ Add necessary bidding parameters to the model, i.e., market energy price. @@ -399,7 +380,6 @@ def _add_bidding_params(self, model): return def _add_bidding_vars(self, model): - """ Add necessary bidding parameters to the model, i.e., market energy price. @@ -433,7 +413,6 @@ def relaxed_day_ahead_power_ub_rule(fs, t): return def _add_bidding_objective(self, model): - """ Add objective function to the model, i.e., maximizing the expected profit of the energy system. @@ -482,7 +461,6 @@ def _compute_bids( energy_price_param_name, market, ): - """ Solve the model to bid into the markets. After solving, record the bids from the solve. @@ -525,7 +503,6 @@ def _compute_bids( return bids def compute_day_ahead_bids(self, date, hour=0): - """ Solve the model to bid into the day-ahead market. After solving, record the bids from the solve. @@ -565,7 +542,6 @@ def compute_day_ahead_bids(self, date, hour=0): def compute_real_time_bids( self, date, hour, realized_day_ahead_prices, realized_day_ahead_dispatches ): - """ Solve the model to bid into the real-time market. After solving, record the bids from the solve. @@ -603,7 +579,6 @@ def compute_real_time_bids( ) def _pass_realized_day_ahead_prices(self, realized_day_ahead_prices, date, hour): - """ Pass the realized day-ahead prices into model parameters. @@ -642,7 +617,6 @@ def _pass_realized_day_ahead_prices(self, realized_day_ahead_prices, date, hour) self.real_time_model.fs[s].day_ahead_energy_price[t] = price def _pass_realized_day_ahead_dispatches(self, realized_day_ahead_dispatches, hour): - """ Pass the realized day-ahead dispatches into model and fix the corresponding variables. @@ -670,7 +644,6 @@ def _pass_realized_day_ahead_dispatches(self, realized_day_ahead_dispatches, hou self.real_time_model.fs[s].real_time_underbid_power[t].unfix() def update_day_ahead_model(self, **kwargs): - """ This method updates the parameters in the day-ahead model based on the implemented profiles. @@ -684,7 +657,6 @@ def update_day_ahead_model(self, **kwargs): self._update_model(self.day_ahead_model, **kwargs) def update_real_time_model(self, **kwargs): - """ This method updates the parameters in the real-time model based on the implemented profiles. @@ -698,7 +670,6 @@ def update_real_time_model(self, **kwargs): self._update_model(self.real_time_model, **kwargs) def _update_model(self, model, **kwargs): - """ Update the flowsheets in all the price scenario blocks to advance time step. @@ -719,7 +690,6 @@ def _update_model(self, model, **kwargs): return def record_bids(self, bids, model, date, hour, market): - """ This function records the bids and the details in the underlying bidding model. @@ -749,7 +719,6 @@ def record_bids(self, bids, model, date, hour, market): return def _pass_price_forecasts(self, model, day_ahead_price, real_time_energy_price): - """ Pass the price forecasts into model parameters. @@ -807,7 +776,6 @@ def generator(self, name): class SelfScheduler(StochasticProgramBidder): - """ Wrap a model object to self schedule into the market using stochastic programming. """ @@ -857,7 +825,6 @@ def __init__( self.fixed_to_schedule = fixed_to_schedule def _add_DA_bidding_constraints(self, model): - """ Add bidding constraints to the model, i.e., power outputs in the first stage need to be the same across all the scenarios. @@ -887,7 +854,6 @@ def day_ahead_bidding_constraints_rule(model, s1, s2, t): return def _add_RT_bidding_constraints(self, model): - """ Add bidding constraints to the model, i.e., power outputs in the first stage need to be the same across all the scenarios. @@ -917,7 +883,6 @@ def real_time_bidding_constraints_rule(model, s1, s2, t): return def _assemble_bids(self, model, power_var_name, energy_price_param_name, hour): - """ This methods extract the bids out of the stochastic programming model and organize them into self-schedule bids. @@ -988,7 +953,6 @@ def _assemble_bids(self, model, power_var_name, energy_price_param_name, hour): return bids def _record_bids(self, bids, date, hour, **kwargs): - """ This function records the bids (schedule) we computed for the given date into a DataFrame and temporarily stores the DataFrame in an instance attribute @@ -1032,7 +996,6 @@ def _record_bids(self, bids, date, hour, **kwargs): class Bidder(StochasticProgramBidder): - """ Wrap a model object to bid into the market using stochastic programming. """ @@ -1047,7 +1010,6 @@ def __init__( forecaster, real_time_underbid_penalty=10000, ): - """ Initializes the bidder object. @@ -1081,7 +1043,6 @@ def __init__( ) def _add_DA_bidding_constraints(self, model): - """ Add bidding constraints to the model, i.e., the bid curves need to be nondecreasing. @@ -1115,7 +1076,6 @@ def day_ahead_bidding_constraints_rule(model, s1, s2, t): return def _add_RT_bidding_constraints(self, model): - """ Add bidding constraints to the model, i.e., the bid curves need to be nondecreasing. @@ -1149,7 +1109,6 @@ def real_time_bidding_constraints_rule(model, s1, s2, t): return def _assemble_bids(self, model, power_var_name, energy_price_param_name, hour): - """ This methods extract the bids out of the stochastic programming model and organize them into ( MWh, $ ) pairs. @@ -1279,7 +1238,6 @@ def _assemble_bids(self, model, power_var_name, energy_price_param_name, hour): return full_bids def _record_bids(self, bids, date, hour, **kwargs): - """ This method records the bids we computed for the given date into a DataFrame. This DataFrame has the following columns: gen, date, hour, diff --git a/idaes/apps/grid_integration/coordinator.py b/idaes/apps/grid_integration/coordinator.py index 97542662c1..6c2bf6efd7 100644 --- a/idaes/apps/grid_integration/coordinator.py +++ b/idaes/apps/grid_integration/coordinator.py @@ -28,13 +28,11 @@ def __init__(self, get_configuration, register_plugins): class DoubleLoopCoordinator: - """ Coordinate Prescient, tracker and bidder. """ def __init__(self, bidder, tracker, projection_tracker): - """ Initializes the DoubleLoopCoordinator object and registers functionalities in Prescient's plugin system. @@ -58,7 +56,6 @@ def __init__(self, bidder, tracker, projection_tracker): self.projection_tracker = projection_tracker def register_plugins(self, context, options, plugin_config): - """ Register functionalities in Prescient's plugin system. @@ -101,7 +98,6 @@ def register_plugins(self, context, options, plugin_config): return def get_configuration(self, key): - """ Register customized commandline options. @@ -131,7 +127,6 @@ def prescient_plugin_module(self): return PrescientPluginModule(self.get_configuration, self.register_plugins) def initialize_customized_results(self, options, simulator): - """ This method is outdated. """ @@ -150,7 +145,6 @@ def initialize_customized_results(self, options, simulator): return def push_hourly_stats_to_forecaster(self, prescient_hourly_stats): - """ This method pushes the hourly stats from Prescient to the price forecaster once the hourly stats are published. @@ -191,7 +185,6 @@ def push_day_ahead_stats_to_forecaster( ) def _update_bids(self, gen_dict, bids, start_hour, horizon): - """ This method takes bids and pass the information in the bids to generator dictionary from Prescient. @@ -277,7 +270,6 @@ def _update_non_time_series_params( return def _pass_DA_bid_to_prescient(self, options, ruc_instance, bids): - """ This method passes the bids into the RUC model for day-ahead market clearing. @@ -302,7 +294,6 @@ def _pass_DA_bid_to_prescient(self, options, ruc_instance, bids): return def assemble_project_tracking_signal(self, options, simulator, hour): - """ This function assembles the signals for the tracking model to estimate the state of the bidding model at the beginning of next RUC. @@ -328,7 +319,6 @@ def assemble_project_tracking_signal(self, options, simulator, hour): return market_signals def project_tracking_trajectory(self, options, simulator, ruc_hour): - """ This function projects the full power dispatch trajectory from the tracking model so we can use it to update the bidding model, i.e. advance @@ -407,7 +397,6 @@ def _clone_tracking_model(self): return def _update_static_params(self, gen_dict): - """ Update static parameters in the Prescient generator parameter data dictionary depending on generator type. @@ -477,7 +466,6 @@ def update_static_params(self, options, instance): return def bid_into_DAM(self, options, simulator, ruc_instance, ruc_date, ruc_hour): - """ This function uses the bidding objects to bid into the day-ahead market (DAM). @@ -522,7 +510,6 @@ def bid_into_DAM(self, options, simulator, ruc_instance, ruc_date, ruc_hour): return def fetch_DA_prices(self, options, simulator, result, uc_date, uc_hour): - """ This method fetches the day-ahead market prices from unit commitment results, and save it as a coordinator attribute. @@ -556,7 +543,6 @@ def fetch_DA_prices(self, options, simulator, result, uc_date, uc_hour): self.next_DA_prices = DA_prices def fetch_DA_dispatches(self, options, simulator, result, uc_date, uc_hour): - """ This method fetches the day-ahead dispatches from unit commitment results, and save it as a coordinator attribute. @@ -599,7 +585,6 @@ def fetch_DA_dispatches(self, options, simulator, result, uc_date, uc_hour): self.next_DA_dispatches = DA_dispatches def _pass_RT_bid_to_prescient(self, options, simulator, sced_instance, bids, hour): - """ This method passes the bids into the SCED model for real-time market clearing. @@ -629,7 +614,6 @@ def _pass_RT_bid_to_prescient(self, options, simulator, sced_instance, bids, hou return def bid_into_RTM(self, options, simulator, sced_instance): - """ This function bids into the real-time market. At this moment I just copy the corresponding day-ahead bid here. @@ -664,7 +648,6 @@ def bid_into_RTM(self, options, simulator, sced_instance): def assemble_sced_tracking_market_signals( self, options, simulator, sced_instance, hour ): - """ This function assembles the signals for the tracking model. @@ -700,7 +683,6 @@ def assemble_sced_tracking_market_signals( def _assemble_sced_tracking_market_signals( self, hour, sced_dispatch, tracking_horizon ): - """ This function assembles the signals for the tracking model. @@ -734,7 +716,6 @@ def _assemble_sced_tracking_market_signals( return market_signals def track_sced_signal(self, options, simulator, sced_instance, lmp_sced): - """ This methods uses the tracking object to track the current real-time market signals. @@ -776,7 +757,6 @@ def track_sced_signal(self, options, simulator, sced_instance, lmp_sced): return def update_observed_dispatch(self, options, simulator, ops_stats): - """ This methods extract the actual power delivered by the tracking model and inform Prescient, so Prescient can use this data to calculate the settlement @@ -809,7 +789,6 @@ def update_observed_dispatch(self, options, simulator, ops_stats): return def activate_pending_DA_data(self, options, simulator): - """ This function puts the day-ahead data computed in the day before into effect, i.e. the data for the next day become the data for the current day. @@ -835,7 +814,6 @@ def activate_pending_DA_data(self, options, simulator): self.current_avail_DA_dispatches = self.current_DA_dispatches def write_plugin_results(self, options, simulator): - """ After the simulation is completed, the plugins can write their own customized results. Each plugin will have to have a method named 'write_results'. diff --git a/idaes/apps/grid_integration/examples/thermal_generator.py b/idaes/apps/grid_integration/examples/thermal_generator.py index 41aa954142..6cafe36464 100644 --- a/idaes/apps/grid_integration/examples/thermal_generator.py +++ b/idaes/apps/grid_integration/examples/thermal_generator.py @@ -24,7 +24,6 @@ class ThermalGenerator: - """ Simple thermal generator model (MIP). Equations models are from Gao, Knueven, Siirola, Miller, Dowling (2022). Multiscale Simulation of Integrated Energy @@ -40,7 +39,6 @@ def __init__( rts_gmlc_bus_dataframe, generator="102_STEAM_3", ): - """ Initializes the class object by building the thermal generator model. @@ -66,7 +64,6 @@ def __init__( self.result_list = [] def assemble_model_data(self, generator_name, gen_params): - """ This function assembles the parameter data to build the thermal generator model, given a list of generator names and the RTS-GMLC data directory. @@ -175,7 +172,6 @@ def model_data(self): @staticmethod def _add_UT_DT_constraints(b): - """ This function adds the minimum up/down time constraints using eq. 4 - 5 in "On mixed-integer programming formulations for the unit commitment @@ -255,7 +251,6 @@ def min_up_time_rule(b, h): return def populate_model(self, b, horizon): - """ This function builds the model for a thermal generator. @@ -550,7 +545,6 @@ def _update_power(b, implemented_power_output): def update_model( self, b, implemented_shut_down, implemented_start_up, implemented_power_output ): - """ This method updates the parameters in the model based on the implemented power outputs, shut down and start up events. @@ -572,7 +566,6 @@ def update_model( @staticmethod def get_implemented_profile(b, last_implemented_time_step): - """ This method gets the implemented variable profiles in the last optimization solve. @@ -605,7 +598,6 @@ def get_implemented_profile(b, last_implemented_time_step): @staticmethod def get_last_delivered_power(b, last_implemented_time_step): - """ Returns the last delivered power output. @@ -619,7 +611,6 @@ def get_last_delivered_power(b, last_implemented_time_step): return pyo.value(b.P_T[last_implemented_time_step]) def record_results(self, b, date=None, hour=None, **kwargs): - """ Record the operations stats for the model. @@ -685,7 +676,6 @@ def record_results(self, b, date=None, hour=None, **kwargs): return def write_results(self, path): - """ This methods writes the saved operation stats into an csv file. diff --git a/idaes/apps/grid_integration/forecaster.py b/idaes/apps/grid_integration/forecaster.py index c22de243e3..7dbc435d40 100644 --- a/idaes/apps/grid_integration/forecaster.py +++ b/idaes/apps/grid_integration/forecaster.py @@ -24,7 +24,6 @@ class ForecastError(Exception): class AbstractPriceForecaster(ABC): - """ The abstract class for price forecaster. """ @@ -56,7 +55,6 @@ def forecast_day_ahead_and_real_time_prices( @abstractmethod def forecast_real_time_prices(self, date, hour, bus, horizon, n_samples): - """ Forecast real-time market prices. @@ -78,7 +76,6 @@ def forecast_real_time_prices(self, date, hour, bus, horizon, n_samples): @abstractmethod def forecast_day_ahead_prices(self, date, hour, bus, horizon, n_samples): - """ Forecast day-ahead market prices. @@ -100,14 +97,12 @@ def forecast_day_ahead_prices(self, date, hour, bus, horizon, n_samples): class AbstractPrescientPriceForecaster(AbstractPriceForecaster): - """ Abstract class for price forecasters that will interface with Prescient. """ @abstractmethod def fetch_hourly_stats_from_prescient(self, prescient_hourly_stats): - """ This method fetches the hourly stats from Prescient to the price forecaster once the hourly stats are published. @@ -121,7 +116,6 @@ def fetch_hourly_stats_from_prescient(self, prescient_hourly_stats): @abstractmethod def fetch_day_ahead_stats_from_prescient(self, uc_date, uc_hour, day_ahead_result): - """ This method fetches the day-ahead market to the price forecaster after the UC is solved from Prescient through the coordinator. @@ -139,7 +133,6 @@ def fetch_day_ahead_stats_from_prescient(self, uc_date, uc_hour, day_ahead_resul class PlaceHolderForecaster(AbstractPrescientPriceForecaster): - """ This a placeholder for a real price forecaster. This placeholder can takes representative daily values and standard deviations for real-time and @@ -208,7 +201,6 @@ def forecast_day_ahead_and_real_time_prices( return da_forecast, rt_forecast def forecast_day_ahead_prices(self, date, hour, bus, horizon, n_samples): - """ Forecast day-ahead market prices. @@ -237,7 +229,6 @@ def forecast_day_ahead_prices(self, date, hour, bus, horizon, n_samples): ) def forecast_real_time_prices(self, date, hour, bus, horizon, n_samples): - """ Forecast real-time market prices. @@ -266,7 +257,6 @@ def forecast_real_time_prices(self, date, hour, bus, horizon, n_samples): ) def _forecast(self, means, stds, hour, horizon, n_samples): - """ Generate price forecasts. @@ -296,7 +286,6 @@ def _forecast(self, means, stds, hour, horizon, n_samples): return {i: list(forecasts_arr[i]) for i in range(n_samples)} def fetch_hourly_stats_from_prescient(self, prescient_hourly_stats): - """ This method fetches the hourly stats from Prescient to the price forecaster once the hourly stats are published. @@ -311,7 +300,6 @@ def fetch_hourly_stats_from_prescient(self, prescient_hourly_stats): return def fetch_day_ahead_stats_from_prescient(self, uc_date, uc_hour, day_ahead_result): - """ This method fetches the day-ahead market to the price forecaster after the UC is solved from Prescient through the coordinator. @@ -331,7 +319,6 @@ def fetch_day_ahead_stats_from_prescient(self, uc_date, uc_hour, day_ahead_resul class Backcaster(AbstractPrescientPriceForecaster): - """ Generate price forecasts by directly using historical prices. """ @@ -359,7 +346,6 @@ def __init__( self._current_day_rt_prices = {bus: [] for bus in historical_da_prices} def _validate_input_historical_price(self, historical_price): - """ Validate input historical prices. @@ -409,7 +395,6 @@ def _validate_input_historical_price(self, historical_price): @property def max_historical_days(self): - """ Property getter for max_historical_days. @@ -421,7 +406,6 @@ def max_historical_days(self): @max_historical_days.setter def max_historical_days(self, value): - """ Property setter for max_historical_days (validate before setting). @@ -448,7 +432,6 @@ def max_historical_days(self, value): @property def historical_da_prices(self): - """ Property getter for historical_da_prices. @@ -460,7 +443,6 @@ def historical_da_prices(self): @historical_da_prices.setter def historical_da_prices(self, value): - """ Property setter for historical_da_prices (validate before setting). @@ -476,7 +458,6 @@ def historical_da_prices(self, value): @property def historical_rt_prices(self): - """ Property getter for historical_rt_prices. @@ -488,7 +469,6 @@ def historical_rt_prices(self): @historical_rt_prices.setter def historical_rt_prices(self, value): - """ Property setter for historical_rt_prices (validate before setting). @@ -536,7 +516,6 @@ def forecast_day_ahead_and_real_time_prices( return da_forecast, rt_forecast def forecast_real_time_prices(self, date, hour, bus, horizon, n_samples): - """ Forecast real-time market prices. @@ -567,7 +546,6 @@ def forecast_real_time_prices(self, date, hour, bus, horizon, n_samples): ) def forecast_day_ahead_prices(self, date, hour, bus, horizon, n_samples): - """ Forecast day-ahead market prices. @@ -643,7 +621,6 @@ def _forecast( return forecast def fetch_hourly_stats_from_prescient(self, prescient_hourly_stats): - """ This method fetches the hourly real-time prices from Prescient and store them on the price forecaster, once they are published. When the stored historical @@ -675,7 +652,6 @@ def fetch_hourly_stats_from_prescient(self, prescient_hourly_stats): return def fetch_day_ahead_stats_from_prescient(self, uc_date, uc_hour, day_ahead_result): - """ This method fetches the hourly day-ahead prices from Prescient and store them on the price forecaster, once they are published. When the stored historical diff --git a/idaes/apps/grid_integration/model_data.py b/idaes/apps/grid_integration/model_data.py index 60e5b92b2b..d2a44c0218 100644 --- a/idaes/apps/grid_integration/model_data.py +++ b/idaes/apps/grid_integration/model_data.py @@ -17,7 +17,6 @@ class BaseValidator(ABC): - """ A base data descriptor that validate values before store them. """ @@ -38,7 +37,6 @@ def __get__(self, instance, cls): @abstractmethod def _validate(self, instance, value): - """ Validate the provided value. @@ -58,7 +56,6 @@ def _validate(self, instance, value): class RealValueValidator(BaseValidator): - """ A data descriptor that validate whether a value is a real number and whether it is within its lower and upper bounds (if provided). @@ -69,7 +66,6 @@ def __init__(self, min_val=None, max_val=None): self.max_val = max_val def _validate(self, instance, value): - """ Validate whether the provided value is within bounds and is a real number. @@ -99,7 +95,6 @@ def _validate(self, instance, value): class AtLeastPminValidator(BaseValidator): - """ A data descriptor that validate whether a value is greater or equal to the generator's Pmin. These values include Pmax, shut-down capacity, start-up @@ -107,7 +102,6 @@ class AtLeastPminValidator(BaseValidator): """ def _validate(self, instance, value): - """ Validate whether the provided value is at least Pmin. @@ -133,7 +127,6 @@ def _validate(self, instance, value): class GeneratorModelData: - """ A class that holds data for generator parameters. """ @@ -190,7 +183,6 @@ def __next__(self): class ThermalGeneratorModelData(GeneratorModelData): - """ Adds run time, ramping, shutdown and startup information for thermal generators. Requires as initial status and power production. @@ -251,7 +243,6 @@ def __init__( self.startup_cost = self._assemble_default_startup_cost_bids(startup_cost_pairs) def _check_empty_and_sort_cost_pairs(self, pair_description, pairs): - """ Check whether a list of pairs for production and startup costs is empty, and then sort them based on power output and startup lag. @@ -274,7 +265,6 @@ def _check_empty_and_sort_cost_pairs(self, pair_description, pairs): return def _assemble_default_cost_bids(self, production_cost_bid_pairs): - """ Assemble the default production cost bids. @@ -311,7 +301,6 @@ def _assemble_default_cost_bids(self, production_cost_bid_pairs): return production_cost_bid_pairs def _assemble_default_startup_cost_bids(self, startup_cost_pairs): - """ Assemble the default startup cost bids. @@ -343,7 +332,6 @@ def generator_type(self): @property def initial_status(self): - """ Generator initial status proptery. If positive, the number of hours prior to (and including) t=0 that the unit has been on. If negative, the number @@ -355,7 +343,6 @@ def initial_status(self): @initial_status.setter def initial_status(self, value): - """ Generator initial status proptery setter. Validate the value before setting. """ @@ -377,7 +364,6 @@ def initial_p_output(self): @initial_p_output.setter def initial_p_output(self, value): - """ Generator initial power output proptery setter. """ @@ -403,7 +389,6 @@ def initial_p_output(self, value): class RenewableGeneratorModelData(GeneratorModelData): - """ Adds a single production cost for renewable generators. """ diff --git a/idaes/apps/grid_integration/tests/test_bidder.py b/idaes/apps/grid_integration/tests/test_bidder.py index 2a565d16bf..677495fd26 100644 --- a/idaes/apps/grid_integration/tests/test_bidder.py +++ b/idaes/apps/grid_integration/tests/test_bidder.py @@ -23,7 +23,6 @@ class TestMissingModel: - """ A class for testing missing methods and attributes. """ @@ -38,7 +37,6 @@ class TestMissingModel: } def __init__(self, missing_method=None, missing_attr=None): - """ Constructs a model class without the specified missing methods and/or missing attributes. diff --git a/idaes/apps/grid_integration/tests/test_tracker.py b/idaes/apps/grid_integration/tests/test_tracker.py index a561fe76d2..13ad5b2b65 100644 --- a/idaes/apps/grid_integration/tests/test_tracker.py +++ b/idaes/apps/grid_integration/tests/test_tracker.py @@ -17,7 +17,6 @@ class TestMissingModel: - """ A class for testing missing methods and attributes. """ diff --git a/idaes/apps/grid_integration/tests/util.py b/idaes/apps/grid_integration/tests/util.py index 5c7be8a8f6..050f37603c 100644 --- a/idaes/apps/grid_integration/tests/util.py +++ b/idaes/apps/grid_integration/tests/util.py @@ -23,13 +23,11 @@ class TestingModel: - """ Simple model object for testing. """ def __init__(self, model_data): - """ Initializes the class object by building the thermal generator model. @@ -61,7 +59,6 @@ def model_data(self): return self._model_data def populate_model(self, b, horizon): - """ This function builds the model for a thermal generator. @@ -125,7 +122,6 @@ def _update_power(b, implemented_power_output): return def update_model(self, b, implemented_power_output): - """ This method updates the parameters in the model based on the implemented power outputs, shut down and start up events. @@ -144,7 +140,6 @@ def update_model(self, b, implemented_power_output): @staticmethod def get_implemented_profile(b, last_implemented_time_step): - """ This method gets the implemented variable profiles in the last optimization solve. @@ -168,7 +163,6 @@ def get_implemented_profile(b, last_implemented_time_step): @staticmethod def get_last_delivered_power(b, last_implemented_time_step): - """ Returns the last delivered power output. @@ -182,7 +176,6 @@ def get_last_delivered_power(b, last_implemented_time_step): return pyo.value(b.P_T[last_implemented_time_step]) def record_results(self, b, date=None, hour=None, **kwargs): - """ Record the operations stats for the model. @@ -242,7 +235,6 @@ def record_results(self, b, date=None, hour=None, **kwargs): return def write_results(self, path): - """ This methods writes the saved operation stats into an csv file. @@ -343,7 +335,6 @@ def fetch_day_ahead_stats_from_prescient(self, uc_date, uc_hour, day_ahead_resul def make_testing_forecaster(): - """ Create a forecaster for testing. @@ -380,7 +371,6 @@ def make_testing_tracker(): def make_testing_bidder(): - """ Create a bidder for testing. @@ -407,7 +397,6 @@ def make_testing_bidder(): def make_testing_selfscheduler(): - """ Create a self-scheduler for testing. diff --git a/idaes/apps/grid_integration/tracker.py b/idaes/apps/grid_integration/tracker.py index 9f084766f6..04d0ac1044 100644 --- a/idaes/apps/grid_integration/tracker.py +++ b/idaes/apps/grid_integration/tracker.py @@ -17,7 +17,6 @@ class Tracker: - """ Wrap a model object to track the market dispatch signals. This class interfaces with the DoubleLoopCoordinator. @@ -26,7 +25,6 @@ class Tracker: def __init__( self, tracking_model_object, tracking_horizon, n_tracking_hour, solver ): - """ Initializes the tracker object. @@ -70,7 +68,6 @@ def __init__( self.result_list = [] def _check_inputs(self): - """ Check if the inputs to construct the tracker is valid. If not raise errors. """ @@ -80,7 +77,6 @@ def _check_inputs(self): self._check_solver() def _check_tracking_model_object(self): - """ Check if tracking model object has the necessary methods and attributes. """ @@ -119,7 +115,6 @@ def _check_tracking_model_object(self): ) def _check_n_tracking_hour(self): - """ Check if the number of hour for tracking is an integer and greater than 0. """ @@ -138,7 +133,6 @@ def _check_n_tracking_hour(self): ) def _check_solver(self): - """ Check if provides solver is a valid Pyomo solver object. """ @@ -151,7 +145,6 @@ def _check_solver(self): ) def formulate_tracking_problem(self): - """ Formulate the tracking optimization problem by adding necessary parameters, constraints, and objective function. @@ -171,7 +164,6 @@ def formulate_tracking_problem(self): return def _add_tracking_vars(self): - """ Add necessary tracking variables to the model, i.e., power under and over delivered. @@ -193,7 +185,6 @@ def _add_tracking_vars(self): return def _add_tracking_params(self): - """ Add necessary tracking parameters to the model, i.e., market dispatch signal. @@ -226,7 +217,6 @@ def _add_tracking_params(self): return def _add_tracking_constraints(self): - """ Add necessary tracking constraints to the model, e.g., power output needs to follow market dispatch signals. @@ -252,7 +242,6 @@ def tracking_dispatch_constraint_rule(m, t): return def _add_tracking_objective(self): - """ Add EMPC objective function to the model, i.e., minimizing different costs of the energy system. @@ -279,7 +268,6 @@ def _add_tracking_objective(self): return def update_model(self, **profiles): - """ This method updates the parameters in the model based on the implemented profiles. @@ -293,7 +281,6 @@ def update_model(self, **profiles): self.tracking_model_object.update_model(self.model.fs, **profiles) def track_market_dispatch(self, market_dispatch, date, hour): - """ Solve the model to track the market dispatch signals. After solving, record the results from the solve and update the model. @@ -326,7 +313,6 @@ def track_market_dispatch(self, market_dispatch, date, hour): return profiles def _record_daily_stats(self, profiles): - """ Record the stats that are used to update the model in the past 24 hours. @@ -350,7 +336,6 @@ def _record_daily_stats(self, profiles): return def _pass_market_dispatch(self, market_dispatch): - """ Pass the received market signals into model parameters. @@ -374,7 +359,6 @@ def _pass_market_dispatch(self, market_dispatch): return def get_last_delivered_power(self): - """ Returns the last delivered power output. @@ -389,7 +373,6 @@ def get_last_delivered_power(self): ) def _record_tracker_results(self, **kwargs): - """ Record the tracker stats. @@ -429,7 +412,6 @@ def _record_tracker_results(self, **kwargs): self.result_list.append(pd.concat(df_list)) def record_results(self, **kwargs): - """ Record the operations stats for the model. diff --git a/idaes/apps/grid_integration/utils.py b/idaes/apps/grid_integration/utils.py index a8df251354..65a960484f 100644 --- a/idaes/apps/grid_integration/utils.py +++ b/idaes/apps/grid_integration/utils.py @@ -13,7 +13,6 @@ def convert_marginal_costs_to_actual_costs(power_marginal_cost_pairs): - """ Convert a list of power and marginal cost pairs to a list of power and actual cost pairs. diff --git a/idaes/apps/nmpc/cost_expressions.py b/idaes/apps/nmpc/cost_expressions.py index f892608e27..ea19b4ddd8 100644 --- a/idaes/apps/nmpc/cost_expressions.py +++ b/idaes/apps/nmpc/cost_expressions.py @@ -47,9 +47,11 @@ def get_tracking_cost_from_constant_setpoint( """ variable_names = [ - str(ComponentUID(var)) - if not var.is_reference() - else str(ComponentUID(var.referent)) + ( + str(ComponentUID(var)) + if not var.is_reference() + else str(ComponentUID(var.referent)) + ) for var in variables ] if weight_data is None: diff --git a/idaes/apps/uncertainty_propagation/uncertainties.py b/idaes/apps/uncertainty_propagation/uncertainties.py index 89b5881851..c24548ef42 100644 --- a/idaes/apps/uncertainty_propagation/uncertainties.py +++ b/idaes/apps/uncertainty_propagation/uncertainties.py @@ -215,7 +215,6 @@ def quantify_propagate_uncertainty( def propagate_uncertainty( model_uncertain, theta, cov, theta_names, tee=False, solver_options=None ): - """This function calculates gradient vector, expectation, and variance of the objective function and constraints of the model for given estimated optimal parameters and covariance matrix of parameters. diff --git a/idaes/core/base/control_volume0d.py b/idaes/core/base/control_volume0d.py index e2a9fbb435..0bda2fbb4e 100644 --- a/idaes/core/base/control_volume0d.py +++ b/idaes/core/base/control_volume0d.py @@ -1650,14 +1650,14 @@ def _get_performance_contents(self, time_point=0): ] if hasattr(self, "equilibrium_reaction_extent"): for r in self.config.reaction_package.equilibrium_reaction_idx: - var_dict[ - f"Equilibrium Reaction Extent [{r}]" - ] = self.equilibrium_reaction_extent[time_point, r] + var_dict[f"Equilibrium Reaction Extent [{r}]"] = ( + self.equilibrium_reaction_extent[time_point, r] + ) if hasattr(self, "phase_equilibrium_generation"): for r in self.config.property_package.phase_equilibrium_idx: - var_dict[ - f"Phase Equilibrium Generation [{r}]" - ] = self.phase_equilibrium_generation[time_point, r] + var_dict[f"Phase Equilibrium Generation [{r}]"] = ( + self.phase_equilibrium_generation[time_point, r] + ) e_vars = { "element_holdup": "Elemental Holdup", diff --git a/idaes/core/base/process_base.py b/idaes/core/base/process_base.py index b89ba964bc..b0ff0be520 100644 --- a/idaes/core/base/process_base.py +++ b/idaes/core/base/process_base.py @@ -564,9 +564,9 @@ def _get_property_package(self): # Check for any flowsheet level build arguments for k in self.config.property_package.config.default_arguments: if k not in self.config.property_package_args: - self.config.property_package_args[ - k - ] = self.config.property_package.config.default_arguments[k] + self.config.property_package_args[k] = ( + self.config.property_package.config.default_arguments[k] + ) def _get_default_prop_pack(self): """ @@ -647,9 +647,9 @@ def _get_reaction_package(self): # Check for any flowsheet level build arguments for k in self.config.reaction_package.config.default_arguments: if k not in self.config.reaction_package_args: - self.config.reaction_package_args[ - k - ] = self.config.reaction_package.config.default_arguments[k] + self.config.reaction_package_args[k] = ( + self.config.reaction_package.config.default_arguments[k] + ) def calculate_scaling_factors(self): # This lets you call super().calculate_scaling_factors() in a unit diff --git a/idaes/core/base/property_meta.py b/idaes/core/base/property_meta.py index 502e11b15d..13886b0979 100644 --- a/idaes/core/base/property_meta.py +++ b/idaes/core/base/property_meta.py @@ -384,9 +384,7 @@ def HEAT_TRANSFER_COEFFICIENT(self): # Entropy @property def ENTROPY(self): - return ( - self._mass * self._length**2 * self._time**-2 * self._temperature**-1 - ) + return self._mass * self._length**2 * self._time**-2 * self._temperature**-1 @property def ENTROPY_MASS(self): diff --git a/idaes/core/base/tests/test_property_meta.py b/idaes/core/base/tests/test_property_meta.py index 3ed90a2086..5cabf3daa4 100644 --- a/idaes/core/base/tests/test_property_meta.py +++ b/idaes/core/base/tests/test_property_meta.py @@ -194,9 +194,7 @@ def test_luminous_intensity(unit_set): "dynamic_viscosity": (units.kg * units.m**-1 * units.s**-1), "entropy": (units.kg * units.m**2 * units.s**-2 * units.K**-1), "entropy_mass": (units.m**2 * units.s**-2 * units.K**-1), - "entropy_mole": ( - units.kg * units.m**2 * units.s**-2 * units.K**-1 * units.mol**-1 - ), + "entropy_mole": (units.kg * units.m**2 * units.s**-2 * units.K**-1 * units.mol**-1), "power": (units.kg * units.m**2 * units.s**-3), "voltage": (units.kg * units.m**2 * units.s**-3 * units.ampere**-1), "pressure": (units.kg * units.m**-1 * units.s**-2), @@ -206,9 +204,7 @@ def test_luminous_intensity(unit_set): ), "heat_transfer_coefficient": (units.kg * units.s**-3 * units.K**-1), "thermal_conductivity": (units.kg * units.m * units.s**-3 * units.K**-1), - "gas_constant": ( - units.kg * units.m**2 * units.s**-2 * units.K**-1 * units.mol**-1 - ), + "gas_constant": (units.kg * units.m**2 * units.s**-2 * units.K**-1 * units.mol**-1), } diff --git a/idaes/core/dmf/cli.py b/idaes/core/dmf/cli.py index ba0b0ce282..a6d772911c 100644 --- a/idaes/core/dmf/cli.py +++ b/idaes/core/dmf/cli.py @@ -1250,9 +1250,9 @@ def dateize(v): if k in ("created", "modified"): result[k] = dateize(v) elif k == "version_info": - result[ - "version" - ] = f"{resource.format_version(v['version'])} @ {dateize(v['created'])}" + result["version"] = ( + f"{resource.format_version(v['version'])} @ {dateize(v['created'])}" + ) elif k == "relations": relations = [] for rel in v: diff --git a/idaes/core/solvers/tests/test_petsc_pid.py b/idaes/core/solvers/tests/test_petsc_pid.py index 89ef7df242..a2473388ff 100644 --- a/idaes/core/solvers/tests/test_petsc_pid.py +++ b/idaes/core/solvers/tests/test_petsc_pid.py @@ -245,7 +245,7 @@ def inlet_pressure_eqn(b, t): assert pyo.value( tj2.get_vec(m.fs.valve_1.control_volume.properties_in[24].pressure)[20] ) == pytest.approx(6e5) - # make sure after the controller comes on the presure goes to the set point + # make sure after the controller comes on the pressure goes to the set point assert pyo.value( tj2.get_vec(m.fs.tank.control_volume.properties_out[24].pressure)[9] ) == pytest.approx(3e5) diff --git a/idaes/core/surrogate/pysmo/kriging.py b/idaes/core/surrogate/pysmo/kriging.py index ae4329f523..ad04fffb0c 100644 --- a/idaes/core/surrogate/pysmo/kriging.py +++ b/idaes/core/surrogate/pysmo/kriging.py @@ -389,13 +389,9 @@ def numerical_gradient(self, var_vector, x, y, p): of_plus = self.objective_function(var_vector_plus, x, y, p) of_minus = self.objective_function(var_vector_minus, x, y, p) grad_current = (of_plus - of_minus) / (2 * eps) - grad_vec[ - i, - ] = grad_current + grad_vec[i,] = grad_current if self.regularization is False: - grad_vec[ - -1, - ] = 0 + grad_vec[-1,] = 0 return grad_vec def parameter_optimization(self, p): diff --git a/idaes/core/surrogate/pysmo/polynomial_regression.py b/idaes/core/surrogate/pysmo/polynomial_regression.py index 5c0ed99edf..7d41719015 100644 --- a/idaes/core/surrogate/pysmo/polynomial_regression.py +++ b/idaes/core/surrogate/pysmo/polynomial_regression.py @@ -485,7 +485,6 @@ def __init__( self.fit_status = None def training_test_data_creation(self, additional_features=None): - """ The training_test_data_creation splits data into training and test data sets. @@ -601,9 +600,7 @@ def polygeneration( x_train_data = x_input_train_data # Generate the constant and pure power terms for i in range(2, polynomial_order + 1): - x_train_data = np.concatenate( - (x_train_data, x_input_train_data**i), axis=1 - ) + x_train_data = np.concatenate((x_train_data, x_input_train_data**i), axis=1) if multinomials == 1: # Next, generate first order multinomials @@ -1295,7 +1292,7 @@ def polynomial_regression_fitting(self, additional_regression_features=None): # PYLINT-WHY: pylint considers self.no_adaptive_samples to be None here # pylint: disable=invalid-unary-operand-type -self.no_adaptive_samples :, - : + :, # pylint: enable=invalid-unary-operand-type ] self.regression_data = np.concatenate( @@ -1856,23 +1853,9 @@ def confint_regression(self, confidence=0.95): # Evaluate confidence intervals, Tabulate and print results c_data = np.zeros((self.optimal_weights_array.shape[0], 4)) c_data[:, 0] = self.optimal_weights_array[:, 0] - c_data[:, 1] = ss_reg_params[ - :, - ] - c_data[:, 2] = ( - self.optimal_weights_array[:, 0] - - t_dist - * ss_reg_params[ - :, - ] - ) - c_data[:, 3] = ( - self.optimal_weights_array[:, 0] - + t_dist - * ss_reg_params[ - :, - ] - ) + c_data[:, 1] = ss_reg_params[:,] + c_data[:, 2] = self.optimal_weights_array[:, 0] - t_dist * ss_reg_params[:,] + c_data[:, 3] = self.optimal_weights_array[:, 0] + t_dist * ss_reg_params[:,] headers = [ "Regression coeff.", diff --git a/idaes/core/surrogate/pysmo/tests/test_polynomial_regression.py b/idaes/core/surrogate/pysmo/tests/test_polynomial_regression.py index 97f87aca93..2830d225c6 100644 --- a/idaes/core/surrogate/pysmo/tests/test_polynomial_regression.py +++ b/idaes/core/surrogate/pysmo/tests/test_polynomial_regression.py @@ -1257,15 +1257,8 @@ def test_bfgs_parameter_optimization_01(self, array_type): x = input_array[:, 0] y = input_array[:, 1] x_vector = np.zeros((x.shape[0], 3)) - x_vector[:, 0] = ( - x[ - :, - ] - ** 2 - ) - x_vector[:, 1] = x[ - :, - ] + x_vector[:, 0] = x[:,] ** 2 + x_vector[:, 1] = x[:,] x_vector[:, 2] = 1 expected_value = np.array([[1.0], [2.0], [1.0]]).reshape( 3, @@ -1329,15 +1322,8 @@ def test_mle_estimate_01(self): x = input_array[:, 0] y = input_array[:, 1] x_vector = np.zeros((x.shape[0], 3)) - x_vector[:, 0] = ( - x[ - :, - ] - ** 2 - ) - x_vector[:, 1] = x[ - :, - ] + x_vector[:, 0] = x[:,] ** 2 + x_vector[:, 1] = x[:,] x_vector[:, 2] = 1 expected_value = np.array([[1.0], [2.0], [1.0]]).reshape( 3, diff --git a/idaes/core/surrogate/pysmo/tests/test_radial_basis_function.py b/idaes/core/surrogate/pysmo/tests/test_radial_basis_function.py index 4f4d3147ab..122982ea7c 100644 --- a/idaes/core/surrogate/pysmo/tests/test_radial_basis_function.py +++ b/idaes/core/surrogate/pysmo/tests/test_radial_basis_function.py @@ -720,15 +720,8 @@ def test_bfgs_parameter_optimization_01(self, array_type): x = input_array[:, 0] y = input_array[:, 1] x_vector = np.zeros((x.shape[0], 3)) - x_vector[:, 0] = ( - x[ - :, - ] - ** 2 - ) - x_vector[:, 1] = x[ - :, - ] + x_vector[:, 0] = x[:,] ** 2 + x_vector[:, 1] = x[:,] x_vector[:, 2] = 1 expected_value = np.array([[1.0], [2.0], [1.0]]).reshape( 3, @@ -783,15 +776,8 @@ def test_explicit_linear_algebra_solution_01(self): x = input_array[:, 0] y = input_array[:, 1] x_vector = np.zeros((x.shape[0], 3)) - x_vector[:, 0] = ( - x[ - :, - ] - ** 2 - ) - x_vector[:, 1] = x[ - :, - ] + x_vector[:, 0] = x[:,] ** 2 + x_vector[:, 1] = x[:,] x_vector[:, 2] = 1 expected_value = np.array([[1.0], [2.0], [1.0]]).reshape( 3, @@ -837,15 +823,8 @@ def test_pyomo_optimization_01(self): x = input_array[:, 0] y = input_array[:, 1] x_vector = np.zeros((x.shape[0], 3)) - x_vector[:, 0] = ( - x[ - :, - ] - ** 2 - ) - x_vector[:, 1] = x[ - :, - ] + x_vector[:, 0] = x[:,] ** 2 + x_vector[:, 1] = x[:,] x_vector[:, 2] = 1 expected_value = np.array([[1.0], [2.0], [1.0]]) output_1 = RadialBasisFunctions.pyomo_optimization(x_vector, y) diff --git a/idaes/core/util/constants.py b/idaes/core/util/constants.py index e3d2c70a07..47a9eecf9b 100644 --- a/idaes/core/util/constants.py +++ b/idaes/core/util/constants.py @@ -68,9 +68,7 @@ class Constants: acceleration_gravity = 9.80665 * units.metre / units.second**2 # https://physics.nist.gov/cgi-bin/cuu/Value?bg - gravitational_constant = ( - 6.67430e-11 * units.metre**3 / units.kg / units.second**2 - ) + gravitational_constant = 6.67430e-11 * units.metre**3 / units.kg / units.second**2 # https://physics.nist.gov/cgi-bin/cuu/Value?me mass_electron = 9.1093837015e-31 * units.kilogram diff --git a/idaes/core/util/model_serializer.py b/idaes/core/util/model_serializer.py index 4b565499a7..79b9193bdf 100644 --- a/idaes/core/util/model_serializer.py +++ b/idaes/core/util/model_serializer.py @@ -604,7 +604,7 @@ def _write_component_data(sd, o, wts, count=None, lookup=None, suffixes=None): continue sd[lookup[id(key)]] = el # Assume keys are Pyomo model components else: # rest of components with normal component data structure - frst = True # on first item when true + is_first_item = True # on first item when true try: item_keys = o.keys() except AttributeError: @@ -614,12 +614,12 @@ def _write_component_data(sd, o, wts, count=None, lookup=None, suffixes=None): el = o else: el = o[key] - if frst: # assume all item are same type, use first to get alist + if is_first_item: # assume all item are same type, use first to get alist # Get all attributes (alist, _) = wts.get_data_class_attr_list(el) if alist is None: return # if None then skip writing - frst = False # done with first only stuff + is_first_item = False # done with first only stuff edict = {"__type__": str(type(el))} if Suffix in wts.classes: # if writing suffixes give data components an id edict["__id__"] = count.count diff --git a/idaes/core/util/model_statistics.py b/idaes/core/util/model_statistics.py index 392e6a8fc2..e67d766e07 100644 --- a/idaes/core/util/model_statistics.py +++ b/idaes/core/util/model_statistics.py @@ -30,6 +30,7 @@ _log = idaeslog.getLogger(__name__) + # ------------------------------------------------------------------------- # Generator to handle cases where the input is an indexed Block # Indexed blocks do not have component_data_objects, so we need to iterate diff --git a/idaes/core/util/phase_equilibria.py b/idaes/core/util/phase_equilibria.py index dc22a418da..53f74b1291 100644 --- a/idaes/core/util/phase_equilibria.py +++ b/idaes/core/util/phase_equilibria.py @@ -46,7 +46,6 @@ def Txy_diagram( solver=None, solver_op=None, ): - """ This method generates T-x-y plots. Given the components, pressure and property dictionary this function calls Txy_data() to generate T-x-y data and once the data has diff --git a/idaes/models/costing/SSLW.py b/idaes/models/costing/SSLW.py index d045ee00d4..9397ef29dc 100644 --- a/idaes/models/costing/SSLW.py +++ b/idaes/models/costing/SSLW.py @@ -1167,8 +1167,7 @@ def base_cost_per_unit_eq(blk): return blk.base_cost_per_unit == ( pyo.exp( alpha[1] - - alpha[2] - * pyo.log(Qcfm / (pyo.units.foot**3 / pyo.units.minute)) + - alpha[2] * pyo.log(Qcfm / (pyo.units.foot**3 / pyo.units.minute)) + alpha[3] * pyo.log(Qcfm / (pyo.units.foot**3 / pyo.units.minute)) ** 2 ) diff --git a/idaes/models/properties/general_helmholtz/components/parameters/r1234ze.py b/idaes/models/properties/general_helmholtz/components/parameters/r1234ze.py index 250d11024f..3f90b63423 100644 --- a/idaes/models/properties/general_helmholtz/components/parameters/r1234ze.py +++ b/idaes/models/properties/general_helmholtz/components/parameters/r1234ze.py @@ -98,9 +98,7 @@ def viscosity_rule(m): sigma = 5.017e-1 NA = 6.0221408e23 Ts = T / eok - eta0 = (a[0] + a[1] * T + a[2] * T**2 + a[3] * T**3) / ( - a[4] + a[5] * T + T**2 - ) + eta0 = (a[0] + a[1] * T + a[2] * T**2 + a[3] * T**3) / (a[4] + a[5] * T + T**2) Bs = ( sum(b[i] * Ts ** (-0.25 * i) for i in range(0, 7)) + b[7] * Ts**-2.5 diff --git a/idaes/models/properties/general_helmholtz/components/parameters/r134a.py b/idaes/models/properties/general_helmholtz/components/parameters/r134a.py index 6930f4bda9..1b4a9d41f3 100644 --- a/idaes/models/properties/general_helmholtz/components/parameters/r134a.py +++ b/idaes/models/properties/general_helmholtz/components/parameters/r134a.py @@ -159,8 +159,7 @@ def viscosity_rule(m): delta = rho / 5017.053 eta = ( c[1] * delta - + (c[2] / tau**6 + c[3] / tau**2 + c[4] / tau**0.5 + c[5] * tau**2) - * delta**2 + + (c[2] / tau**6 + c[3] / tau**2 + c[4] / tau**0.5 + c[5] * tau**2) * delta**2 + c[6] * delta**3 + c[7] / (delta0 - delta) - c[7] / delta0 diff --git a/idaes/models/properties/general_helmholtz/helmholtz_state.py b/idaes/models/properties/general_helmholtz/helmholtz_state.py index d2239a9859..d00b2a1129 100644 --- a/idaes/models/properties/general_helmholtz/helmholtz_state.py +++ b/idaes/models/properties/general_helmholtz/helmholtz_state.py @@ -520,7 +520,7 @@ def _state_vars(self): self.vapor_frac = pyo.Var( initialize=0.0, units=pyunits.dimensionless, - doc="Vapor fraction" + doc="Vapor fraction", # No bounds here, since it is often (usually) on it's bound # and that's not the best for IPOPT ) diff --git a/idaes/models/properties/modular_properties/base/generic_property.py b/idaes/models/properties/modular_properties/base/generic_property.py index 6fa87a706f..0c1c74a46b 100644 --- a/idaes/models/properties/modular_properties/base/generic_property.py +++ b/idaes/models/properties/modular_properties/base/generic_property.py @@ -4039,10 +4039,12 @@ def _mw(self): expr=sum( self.phase_frac[p] * sum( - self.mole_frac_phase_comp[p, j] - * self.params.get_component(j).mw - if (p, j) in self.phase_component_set - else 0 + ( + self.mole_frac_phase_comp[p, j] + * self.params.get_component(j).mw + if (p, j) in self.phase_component_set + else 0 + ) for j in self.component_list ) for p in self.phase_list @@ -4162,9 +4164,11 @@ def _mw_phase(self): def rule_mw_phase(b, p): return sum( - b.mole_frac_phase_comp[p, j] * b.params.get_component(j).mw - if (p, j) in b.phase_component_set - else 0 + ( + b.mole_frac_phase_comp[p, j] * b.params.get_component(j).mw + if (p, j) in b.phase_component_set + else 0 + ) for j in b.component_list ) diff --git a/idaes/models/properties/modular_properties/base/tests/test_utility.py b/idaes/models/properties/modular_properties/base/tests/test_utility.py index 32469abf50..c2b0034a7f 100644 --- a/idaes/models/properties/modular_properties/base/tests/test_utility.py +++ b/idaes/models/properties/modular_properties/base/tests/test_utility.py @@ -306,9 +306,9 @@ def frame(self): @pytest.mark.unit def test_rate_molarity(self, frame): frame.params.config.rate_reactions["r1"] = rxn_config - frame.params.config.rate_reactions[ - "r1" - ].concentration_form = ConcentrationForm.molarity + frame.params.config.rate_reactions["r1"].concentration_form = ( + ConcentrationForm.molarity + ) assert get_concentration_term(frame, "r1") is frame.conc_mol_phase_comp assert ( @@ -319,9 +319,9 @@ def test_rate_molarity(self, frame): @pytest.mark.unit def test_rate_activity(self, frame): frame.params.config.rate_reactions["r1"] = rxn_config - frame.params.config.rate_reactions[ - "r1" - ].concentration_form = ConcentrationForm.activity + frame.params.config.rate_reactions["r1"].concentration_form = ( + ConcentrationForm.activity + ) assert get_concentration_term(frame, "r1") is frame.act_phase_comp assert get_concentration_term(frame, "r1", log=True) is frame.log_act_phase_comp @@ -329,9 +329,9 @@ def test_rate_activity(self, frame): @pytest.mark.unit def test_rate_molality(self, frame): frame.params.config.rate_reactions["r1"] = rxn_config - frame.params.config.rate_reactions[ - "r1" - ].concentration_form = ConcentrationForm.molality + frame.params.config.rate_reactions["r1"].concentration_form = ( + ConcentrationForm.molality + ) assert get_concentration_term(frame, "r1") is frame.molality_phase_comp assert ( @@ -342,9 +342,9 @@ def test_rate_molality(self, frame): @pytest.mark.unit def test_rate_mole_frac(self, frame): frame.params.config.rate_reactions["r1"] = rxn_config - frame.params.config.rate_reactions[ - "r1" - ].concentration_form = ConcentrationForm.moleFraction + frame.params.config.rate_reactions["r1"].concentration_form = ( + ConcentrationForm.moleFraction + ) assert get_concentration_term(frame, "r1") is frame.mole_frac_phase_comp assert ( @@ -355,9 +355,9 @@ def test_rate_mole_frac(self, frame): @pytest.mark.unit def test_rate_mass_frac(self, frame): frame.params.config.rate_reactions["r1"] = rxn_config - frame.params.config.rate_reactions[ - "r1" - ].concentration_form = ConcentrationForm.massFraction + frame.params.config.rate_reactions["r1"].concentration_form = ( + ConcentrationForm.massFraction + ) assert get_concentration_term(frame, "r1") is frame.mass_frac_phase_comp assert ( @@ -368,9 +368,9 @@ def test_rate_mass_frac(self, frame): @pytest.mark.unit def test_rate_partial_pressure(self, frame): frame.params.config.rate_reactions["r1"] = rxn_config - frame.params.config.rate_reactions[ - "r1" - ].concentration_form = ConcentrationForm.partialPressure + frame.params.config.rate_reactions["r1"].concentration_form = ( + ConcentrationForm.partialPressure + ) assert get_concentration_term(frame, "r1") is frame.pressure_phase_comp assert ( @@ -381,9 +381,9 @@ def test_rate_partial_pressure(self, frame): @pytest.mark.unit def test_equilibrium_molarity(self, frame): frame.params.config.equilibrium_reactions["e1"] = rxn_config - frame.params.config.equilibrium_reactions[ - "e1" - ].concentration_form = ConcentrationForm.molarity + frame.params.config.equilibrium_reactions["e1"].concentration_form = ( + ConcentrationForm.molarity + ) assert get_concentration_term(frame, "e1") is frame.conc_mol_phase_comp assert ( @@ -394,9 +394,9 @@ def test_equilibrium_molarity(self, frame): @pytest.mark.unit def test_equilibrium_activity(self, frame): frame.params.config.equilibrium_reactions["e1"] = rxn_config - frame.params.config.equilibrium_reactions[ - "e1" - ].concentration_form = ConcentrationForm.activity + frame.params.config.equilibrium_reactions["e1"].concentration_form = ( + ConcentrationForm.activity + ) assert get_concentration_term(frame, "e1") is frame.act_phase_comp assert get_concentration_term(frame, "e1", log=True) is frame.log_act_phase_comp @@ -404,9 +404,9 @@ def test_equilibrium_activity(self, frame): @pytest.mark.unit def test_equilibrium_molality(self, frame): frame.params.config.equilibrium_reactions["e1"] = rxn_config - frame.params.config.equilibrium_reactions[ - "e1" - ].concentration_form = ConcentrationForm.molality + frame.params.config.equilibrium_reactions["e1"].concentration_form = ( + ConcentrationForm.molality + ) assert get_concentration_term(frame, "e1") is frame.molality_phase_comp assert ( @@ -417,9 +417,9 @@ def test_equilibrium_molality(self, frame): @pytest.mark.unit def test_equilibrium_mole_frac(self, frame): frame.params.config.equilibrium_reactions["e1"] = rxn_config - frame.params.config.equilibrium_reactions[ - "e1" - ].concentration_form = ConcentrationForm.moleFraction + frame.params.config.equilibrium_reactions["e1"].concentration_form = ( + ConcentrationForm.moleFraction + ) assert get_concentration_term(frame, "e1") is frame.mole_frac_phase_comp assert ( @@ -430,9 +430,9 @@ def test_equilibrium_mole_frac(self, frame): @pytest.mark.unit def test_equilibrium_mass_frac(self, frame): frame.params.config.equilibrium_reactions["e1"] = rxn_config - frame.params.config.equilibrium_reactions[ - "e1" - ].concentration_form = ConcentrationForm.massFraction + frame.params.config.equilibrium_reactions["e1"].concentration_form = ( + ConcentrationForm.massFraction + ) assert get_concentration_term(frame, "e1") is frame.mass_frac_phase_comp assert ( @@ -443,9 +443,9 @@ def test_equilibrium_mass_frac(self, frame): @pytest.mark.unit def test_equilibrium_partial_pressure(self, frame): frame.params.config.equilibrium_reactions["e1"] = rxn_config - frame.params.config.equilibrium_reactions[ - "e1" - ].concentration_form = ConcentrationForm.partialPressure + frame.params.config.equilibrium_reactions["e1"].concentration_form = ( + ConcentrationForm.partialPressure + ) assert get_concentration_term(frame, "e1") is frame.pressure_phase_comp assert ( @@ -486,9 +486,9 @@ def frame2(self): @pytest.mark.unit def test_inherent_molarity(self, frame2): frame2.params.config.inherent_reactions["i1"] = rxn_config - frame2.params.config.inherent_reactions[ - "i1" - ].concentration_form = ConcentrationForm.molarity + frame2.params.config.inherent_reactions["i1"].concentration_form = ( + ConcentrationForm.molarity + ) assert get_concentration_term(frame2, "i1") is frame2.conc_mol_phase_comp assert ( @@ -499,9 +499,9 @@ def test_inherent_molarity(self, frame2): @pytest.mark.unit def test_inherent_activity(self, frame2): frame2.params.config.inherent_reactions["i1"] = rxn_config - frame2.params.config.inherent_reactions[ - "i1" - ].concentration_form = ConcentrationForm.activity + frame2.params.config.inherent_reactions["i1"].concentration_form = ( + ConcentrationForm.activity + ) assert get_concentration_term(frame2, "i1") is frame2.act_phase_comp assert ( @@ -511,9 +511,9 @@ def test_inherent_activity(self, frame2): @pytest.mark.unit def test_inherent_molality(self, frame2): frame2.params.config.inherent_reactions["i1"] = rxn_config - frame2.params.config.inherent_reactions[ - "i1" - ].concentration_form = ConcentrationForm.molality + frame2.params.config.inherent_reactions["i1"].concentration_form = ( + ConcentrationForm.molality + ) assert get_concentration_term(frame2, "i1") is frame2.molality_phase_comp assert ( @@ -524,9 +524,9 @@ def test_inherent_molality(self, frame2): @pytest.mark.unit def test_inherent_mole_frac(self, frame2): frame2.params.config.inherent_reactions["i1"] = rxn_config - frame2.params.config.inherent_reactions[ - "i1" - ].concentration_form = ConcentrationForm.moleFraction + frame2.params.config.inherent_reactions["i1"].concentration_form = ( + ConcentrationForm.moleFraction + ) assert get_concentration_term(frame2, "i1") is frame2.mole_frac_phase_comp assert ( @@ -537,9 +537,9 @@ def test_inherent_mole_frac(self, frame2): @pytest.mark.unit def test_inherent_mass_frac(self, frame2): frame2.params.config.inherent_reactions["i1"] = rxn_config - frame2.params.config.inherent_reactions[ - "i1" - ].concentration_form = ConcentrationForm.massFraction + frame2.params.config.inherent_reactions["i1"].concentration_form = ( + ConcentrationForm.massFraction + ) assert get_concentration_term(frame2, "i1") is frame2.mass_frac_phase_comp assert ( @@ -550,9 +550,9 @@ def test_inherent_mass_frac(self, frame2): @pytest.mark.unit def test_inherent_partial_pressure(self, frame2): frame2.params.config.inherent_reactions["i1"] = rxn_config - frame2.params.config.inherent_reactions[ - "i1" - ].concentration_form = ConcentrationForm.partialPressure + frame2.params.config.inherent_reactions["i1"].concentration_form = ( + ConcentrationForm.partialPressure + ) assert get_concentration_term(frame2, "i1") is frame2.pressure_phase_comp assert ( diff --git a/idaes/models/properties/modular_properties/coolprop/tests/test_coolprop_forms.py b/idaes/models/properties/modular_properties/coolprop/tests/test_coolprop_forms.py index e4f22d708a..dfbbe8e5e0 100644 --- a/idaes/models/properties/modular_properties/coolprop/tests/test_coolprop_forms.py +++ b/idaes/models/properties/modular_properties/coolprop/tests/test_coolprop_forms.py @@ -126,8 +126,7 @@ def test_exponential_sum(self, model): expr = cforms._nt_sum(model.params, "pressure_sat", 42) assert str(expr) == str( - model.params.pressure_sat_coeff_n1 - * 42**model.params.pressure_sat_coeff_t1 + model.params.pressure_sat_coeff_n1 * 42**model.params.pressure_sat_coeff_t1 + model.params.pressure_sat_coeff_n2 * 42**model.params.pressure_sat_coeff_t2 + model.params.pressure_sat_coeff_n3 diff --git a/idaes/models/properties/modular_properties/eos/enrtl.py b/idaes/models/properties/modular_properties/eos/enrtl.py index c558319342..93fae2192a 100644 --- a/idaes/models/properties/modular_properties/eos/enrtl.py +++ b/idaes/models/properties/modular_properties/eos/enrtl.py @@ -322,8 +322,7 @@ def rule_log_gamma_pdh(b, j): # Eqn 70 z = abs(cobj(b, j).config.charge) return -A * ( - (2 * z**2 / rho) - * log((1 + rho * Ix**0.5) / (1 + rho * I0**0.5)) + (2 * z**2 / rho) * log((1 + rho * Ix**0.5) / (1 + rho * I0**0.5)) + (z**2 * Ix**0.5 - 2 * Ix ** (3 / 2)) / (1 + rho * Ix**0.5) - (2 * Ix * I0**-0.5) / (1 + rho * I0**0.5) diff --git a/idaes/models/properties/modular_properties/examples/CO2_H2O_Ideal_VLE.py b/idaes/models/properties/modular_properties/examples/CO2_H2O_Ideal_VLE.py index fa9c6a3c6b..c6f59fc3d9 100644 --- a/idaes/models/properties/modular_properties/examples/CO2_H2O_Ideal_VLE.py +++ b/idaes/models/properties/modular_properties/examples/CO2_H2O_Ideal_VLE.py @@ -94,31 +94,19 @@ ), # [1] temperature range 500 K- 1700 K "B": ( 6.832514, - pyunits.J - * pyunits.mol**-1 - * pyunits.K**-1 - * pyunits.kiloK**-1, + pyunits.J * pyunits.mol**-1 * pyunits.K**-1 * pyunits.kiloK**-1, ), "C": ( 6.793435, - pyunits.J - * pyunits.mol**-1 - * pyunits.K**-1 - * pyunits.kiloK**-2, + pyunits.J * pyunits.mol**-1 * pyunits.K**-1 * pyunits.kiloK**-2, ), "D": ( -2.534480, - pyunits.J - * pyunits.mol**-1 - * pyunits.K**-1 - * pyunits.kiloK**-3, + pyunits.J * pyunits.mol**-1 * pyunits.K**-1 * pyunits.kiloK**-3, ), "E": ( 0.082139, - pyunits.J - * pyunits.mol**-1 - * pyunits.K**-1 - * pyunits.kiloK**2, + pyunits.J * pyunits.mol**-1 * pyunits.K**-1 * pyunits.kiloK**2, ), "F": (-250.8810, pyunits.kJ / pyunits.mol), "G": (223.3967, pyunits.J / pyunits.mol / pyunits.K), @@ -158,31 +146,19 @@ "A": (24.99735, pyunits.J / pyunits.mol / pyunits.K), "B": ( 55.18696, - pyunits.J - * pyunits.mol**-1 - * pyunits.K**-1 - * pyunits.kiloK**-1, + pyunits.J * pyunits.mol**-1 * pyunits.K**-1 * pyunits.kiloK**-1, ), "C": ( -33.69137, - pyunits.J - * pyunits.mol**-1 - * pyunits.K**-1 - * pyunits.kiloK**-2, + pyunits.J * pyunits.mol**-1 * pyunits.K**-1 * pyunits.kiloK**-2, ), "D": ( 7.948387, - pyunits.J - * pyunits.mol**-1 - * pyunits.K**-1 - * pyunits.kiloK**-3, + pyunits.J * pyunits.mol**-1 * pyunits.K**-1 * pyunits.kiloK**-3, ), "E": ( -0.136638, - pyunits.J - * pyunits.mol**-1 - * pyunits.K**-1 - * pyunits.kiloK**2, + pyunits.J * pyunits.mol**-1 * pyunits.K**-1 * pyunits.kiloK**2, ), "F": (-403.6075, pyunits.kJ / pyunits.mol), "G": (228.2431, pyunits.J / pyunits.mol / pyunits.K), diff --git a/idaes/models/properties/modular_properties/pure/NIST.py b/idaes/models/properties/modular_properties/pure/NIST.py index 5c524fc5dc..674382b148 100644 --- a/idaes/models/properties/modular_properties/pure/NIST.py +++ b/idaes/models/properties/modular_properties/pure/NIST.py @@ -43,37 +43,25 @@ def build_parameters(cobj): cobj.cp_mol_ig_comp_coeff_B = Var( doc="Shomate B parameter for ideal gas molar heat capacity", - units=pyunits.J - * pyunits.mol**-1 - * pyunits.K**-1 - * pyunits.kiloK**-1, + units=pyunits.J * pyunits.mol**-1 * pyunits.K**-1 * pyunits.kiloK**-1, ) set_param_from_config(cobj, param="cp_mol_ig_comp_coeff", index="B") cobj.cp_mol_ig_comp_coeff_C = Var( doc="Shomate C parameter for ideal gas molar heat capacity", - units=pyunits.J - * pyunits.mol**-1 - * pyunits.K**-1 - * pyunits.kiloK**-2, + units=pyunits.J * pyunits.mol**-1 * pyunits.K**-1 * pyunits.kiloK**-2, ) set_param_from_config(cobj, param="cp_mol_ig_comp_coeff", index="C") cobj.cp_mol_ig_comp_coeff_D = Var( doc="Shomate D parameter for ideal gas molar heat capacity", - units=pyunits.J - * pyunits.mol**-1 - * pyunits.K**-1 - * pyunits.kiloK**-3, + units=pyunits.J * pyunits.mol**-1 * pyunits.K**-1 * pyunits.kiloK**-3, ) set_param_from_config(cobj, param="cp_mol_ig_comp_coeff", index="D") cobj.cp_mol_ig_comp_coeff_E = Var( doc="Shomate E parameter for ideal gas molar heat capacity", - units=pyunits.J - * pyunits.mol**-1 - * pyunits.K**-1 - * pyunits.kiloK**2, + units=pyunits.J * pyunits.mol**-1 * pyunits.K**-1 * pyunits.kiloK**2, ) set_param_from_config(cobj, param="cp_mol_ig_comp_coeff", index="E") diff --git a/idaes/models/properties/modular_properties/reactions/tests/test_equilibrium_constant.py b/idaes/models/properties/modular_properties/reactions/tests/test_equilibrium_constant.py index 11f8d468d5..c2f1970e71 100644 --- a/idaes/models/properties/modular_properties/reactions/tests/test_equilibrium_constant.py +++ b/idaes/models/properties/modular_properties/reactions/tests/test_equilibrium_constant.py @@ -675,11 +675,7 @@ def test_gibbs_energy_mole_frac(self, model): assert str(rform1) == ("exp(rxn[1].log_k_eq[r1])") R = pyunits.convert( c.gas_constant, - to_units=pyunits.kg - * pyunits.m**2 - / pyunits.s**2 - / pyunits.mol - / pyunits.K, + to_units=pyunits.kg * pyunits.m**2 / pyunits.s**2 / pyunits.mol / pyunits.K, ) T = 300 * pyunits.K assert str(rform2) == ( diff --git a/idaes/models/properties/modular_properties/reactions/tests/test_rate_constant.py b/idaes/models/properties/modular_properties/reactions/tests/test_rate_constant.py index d0e57574d0..c54d929f1b 100644 --- a/idaes/models/properties/modular_properties/reactions/tests/test_rate_constant.py +++ b/idaes/models/properties/modular_properties/reactions/tests/test_rate_constant.py @@ -264,9 +264,7 @@ def test_arrhenius_partial_pressure(model): ) assert value(rform) == pytest.approx(0.81836, rel=1e-3) - assert_units_equivalent( - rform, pyunits.mol / pyunits.m**3 / pyunits.s / pyunits.Pa - ) + assert_units_equivalent(rform, pyunits.mol / pyunits.m**3 / pyunits.s / pyunits.Pa) @pytest.mark.unit @@ -299,6 +297,4 @@ def test_arrhenius_partial_pressure_convert(model): ) assert value(rform) == pytest.approx(0.81836, rel=1e-3) - assert_units_equivalent( - rform, pyunits.mol / pyunits.m**3 / pyunits.s / pyunits.Pa - ) + assert_units_equivalent(rform, pyunits.mol / pyunits.m**3 / pyunits.s / pyunits.Pa) diff --git a/idaes/models/properties/modular_properties/state_definitions/tests/test_FpcTP.py b/idaes/models/properties/modular_properties/state_definitions/tests/test_FpcTP.py index 22320c7698..d43c170a4c 100644 --- a/idaes/models/properties/modular_properties/state_definitions/tests/test_FpcTP.py +++ b/idaes/models/properties/modular_properties/state_definitions/tests/test_FpcTP.py @@ -1300,31 +1300,19 @@ def test_cloning(self, frame): "A": (30.09200, pyunits.J / pyunits.mol / pyunits.K), "B": ( 6.832514, - pyunits.J - * pyunits.mol**-1 - * pyunits.K**-1 - * pyunits.kiloK**-1, + pyunits.J * pyunits.mol**-1 * pyunits.K**-1 * pyunits.kiloK**-1, ), "C": ( 6.793435, - pyunits.J - * pyunits.mol**-1 - * pyunits.K**-1 - * pyunits.kiloK**-2, + pyunits.J * pyunits.mol**-1 * pyunits.K**-1 * pyunits.kiloK**-2, ), "D": ( -2.534480, - pyunits.J - * pyunits.mol**-1 - * pyunits.K**-1 - * pyunits.kiloK**-3, + pyunits.J * pyunits.mol**-1 * pyunits.K**-1 * pyunits.kiloK**-3, ), "E": ( 0.082139, - pyunits.J - * pyunits.mol**-1 - * pyunits.K**-1 - * pyunits.kiloK**2, + pyunits.J * pyunits.mol**-1 * pyunits.K**-1 * pyunits.kiloK**2, ), "F": (-250.8810, pyunits.kJ / pyunits.mol), "G": (223.3967, pyunits.J / pyunits.mol / pyunits.K), @@ -1365,31 +1353,19 @@ def test_cloning(self, frame): "A": (24.99735, pyunits.J / pyunits.mol / pyunits.K), "B": ( 55.18696, - pyunits.J - * pyunits.mol**-1 - * pyunits.K**-1 - * pyunits.kiloK**-1, + pyunits.J * pyunits.mol**-1 * pyunits.K**-1 * pyunits.kiloK**-1, ), "C": ( -33.69137, - pyunits.J - * pyunits.mol**-1 - * pyunits.K**-1 - * pyunits.kiloK**-2, + pyunits.J * pyunits.mol**-1 * pyunits.K**-1 * pyunits.kiloK**-2, ), "D": ( 7.948387, - pyunits.J - * pyunits.mol**-1 - * pyunits.K**-1 - * pyunits.kiloK**-3, + pyunits.J * pyunits.mol**-1 * pyunits.K**-1 * pyunits.kiloK**-3, ), "E": ( -0.136638, - pyunits.J - * pyunits.mol**-1 - * pyunits.K**-1 - * pyunits.kiloK**2, + pyunits.J * pyunits.mol**-1 * pyunits.K**-1 * pyunits.kiloK**2, ), "F": (-403.6075, pyunits.kJ / pyunits.mol), "G": (228.2431, pyunits.J / pyunits.mol / pyunits.K), diff --git a/idaes/models/properties/modular_properties/transport_properties/viscosity_wilke.py b/idaes/models/properties/modular_properties/transport_properties/viscosity_wilke.py index cfe08c7542..84c3c04c17 100644 --- a/idaes/models/properties/modular_properties/transport_properties/viscosity_wilke.py +++ b/idaes/models/properties/modular_properties/transport_properties/viscosity_wilke.py @@ -39,9 +39,9 @@ def build_parameters(pobj): pobj.config.transport_property_options.get("viscosity_phi_ij_callback") is None ): - pobj.config.transport_property_options[ - "viscosity_phi_ij_callback" - ] = wilke_phi_ij_callback + pobj.config.transport_property_options["viscosity_phi_ij_callback"] = ( + wilke_phi_ij_callback + ) @staticmethod def build_phi_ij(b, p): diff --git a/idaes/models/unit_models/mscontactor.py b/idaes/models/unit_models/mscontactor.py index 5837066831..68d839e87f 100644 --- a/idaes/models/unit_models/mscontactor.py +++ b/idaes/models/unit_models/mscontactor.py @@ -432,7 +432,7 @@ def _verify_inputs(self): self.stream_component_interactions = Set( doc="Set of interacting components between streams." ) - for (stream1, stream2) in self.stream_interactions: + for stream1, stream2 in self.stream_interactions: for j in self.config.streams[stream1].property_package.component_list: if ( j in self.config.streams[stream2].property_package.component_list diff --git a/idaes/models/unit_models/tests/test_gibbs.py b/idaes/models/unit_models/tests/test_gibbs.py index 91849d893c..92dab2c3cf 100644 --- a/idaes/models/unit_models/tests/test_gibbs.py +++ b/idaes/models/unit_models/tests/test_gibbs.py @@ -279,12 +279,12 @@ def test_solve_temperature(self, methane): methane.scaling_factor[ methane.fs.unit.control_volume.enthalpy_balances[0.0] ] = 6.343688225967796e-08 - methane.scaling_factor[ - methane.fs.unit.control_volume.heat[0.0] - ] = 1.3415588575040103e-07 - methane.scaling_factor[ - methane.fs.unit.control_volume.pressure_balance[0.0] - ] = 9.869232667160129e-06 + methane.scaling_factor[methane.fs.unit.control_volume.heat[0.0]] = ( + 1.3415588575040103e-07 + ) + methane.scaling_factor[methane.fs.unit.control_volume.pressure_balance[0.0]] = ( + 9.869232667160129e-06 + ) methane.scaling_factor[ methane.fs.unit.control_volume.properties_in[0.0].enth_mol_phase["Vap"] ] = 0.00010271414106049353 @@ -796,36 +796,36 @@ def test_solve_temperature(self, methane): methane.scaling_factor[ methane.fs.unit.gibbs_minimization[0.0, "Vap", "CO2"] ] = 7.052606407804767e-07 - methane.scaling_factor[ - methane.fs.unit.gibbs_minimization[0.0, "Vap", "CO"] - ] = 1.1096130740800528e-06 + methane.scaling_factor[methane.fs.unit.gibbs_minimization[0.0, "Vap", "CO"]] = ( + 1.1096130740800528e-06 + ) methane.scaling_factor[ methane.fs.unit.gibbs_minimization[0.0, "Vap", "H2O"] ] = 9.679516364316312e-07 - methane.scaling_factor[ - methane.fs.unit.gibbs_minimization[0.0, "Vap", "H2"] - ] = 1.5736217717559093e-06 - methane.scaling_factor[ - methane.fs.unit.gibbs_minimization[0.0, "Vap", "N2"] - ] = 1.2499361838560746e-06 + methane.scaling_factor[methane.fs.unit.gibbs_minimization[0.0, "Vap", "H2"]] = ( + 1.5736217717559093e-06 + ) + methane.scaling_factor[methane.fs.unit.gibbs_minimization[0.0, "Vap", "N2"]] = ( + 1.2499361838560746e-06 + ) methane.scaling_factor[ methane.fs.unit.gibbs_minimization[0.0, "Vap", "NH3"] ] = 8.304717457164266e-07 - methane.scaling_factor[ - methane.fs.unit.gibbs_minimization[0.0, "Vap", "O2"] - ] = 8.983346084706515e-07 - methane.scaling_factor[ - methane.fs.unit.lagrange_mult[0.0, "C"] - ] = 2.926858666284934e-06 - methane.scaling_factor[ - methane.fs.unit.lagrange_mult[0.0, "H"] - ] = 4.450874503325572e-06 - methane.scaling_factor[ - methane.fs.unit.lagrange_mult[0.0, "N"] - ] = 3.535353406620262e-06 - methane.scaling_factor[ - methane.fs.unit.lagrange_mult[0.0, "O"] - ] = 2.5408739736966393e-06 + methane.scaling_factor[methane.fs.unit.gibbs_minimization[0.0, "Vap", "O2"]] = ( + 8.983346084706515e-07 + ) + methane.scaling_factor[methane.fs.unit.lagrange_mult[0.0, "C"]] = ( + 2.926858666284934e-06 + ) + methane.scaling_factor[methane.fs.unit.lagrange_mult[0.0, "H"]] = ( + 4.450874503325572e-06 + ) + methane.scaling_factor[methane.fs.unit.lagrange_mult[0.0, "N"]] = ( + 3.535353406620262e-06 + ) + methane.scaling_factor[methane.fs.unit.lagrange_mult[0.0, "O"]] = ( + 2.5408739736966393e-06 + ) scaling = TransformationFactory("core.scale_model") sm = scaling.create_using(methane, rename=False) @@ -975,9 +975,9 @@ def test_solve_heat_duty(self, methane): methane.scaling_factor[ methane.fs.unit.control_volume.enthalpy_balances[0.0] ] = 7.199382898409605e-08 - methane.scaling_factor[ - methane.fs.unit.control_volume.pressure_balance[0.0] - ] = 9.869232667160129e-06 + methane.scaling_factor[methane.fs.unit.control_volume.pressure_balance[0.0]] = ( + 9.869232667160129e-06 + ) methane.scaling_factor[ methane.fs.unit.control_volume.properties_in[0.0].enth_mol_phase["Vap"] ] = 0.00010271414106049353 @@ -1492,36 +1492,36 @@ def test_solve_heat_duty(self, methane): methane.scaling_factor[ methane.fs.unit.gibbs_minimization[0.0, "Vap", "CO2"] ] = 7.961846197368761e-07 - methane.scaling_factor[ - methane.fs.unit.gibbs_minimization[0.0, "Vap", "CO"] - ] = 1.306639729794169e-06 + methane.scaling_factor[methane.fs.unit.gibbs_minimization[0.0, "Vap", "CO"]] = ( + 1.306639729794169e-06 + ) methane.scaling_factor[ methane.fs.unit.gibbs_minimization[0.0, "Vap", "H2O"] ] = 1.1245365150847992e-06 - methane.scaling_factor[ - methane.fs.unit.gibbs_minimization[0.0, "Vap", "H2"] - ] = 1.9650913378522065e-06 - methane.scaling_factor[ - methane.fs.unit.gibbs_minimization[0.0, "Vap", "N2"] - ] = 1.5268799321929755e-06 + methane.scaling_factor[methane.fs.unit.gibbs_minimization[0.0, "Vap", "H2"]] = ( + 1.9650913378522065e-06 + ) + methane.scaling_factor[methane.fs.unit.gibbs_minimization[0.0, "Vap", "N2"]] = ( + 1.5268799321929755e-06 + ) methane.scaling_factor[ methane.fs.unit.gibbs_minimization[0.0, "Vap", "NH3"] ] = 1.0314993300171925e-06 - methane.scaling_factor[ - methane.fs.unit.gibbs_minimization[0.0, "Vap", "O2"] - ] = 9.653850829168712e-07 - methane.scaling_factor[ - methane.fs.unit.lagrange_mult[0.0, "C"] - ] = 3.915957066473961e-06 - methane.scaling_factor[ - methane.fs.unit.lagrange_mult[0.0, "H"] - ] = 5.55811764258496e-06 - methane.scaling_factor[ - methane.fs.unit.lagrange_mult[0.0, "N"] - ] = 4.318668616445236e-06 - methane.scaling_factor[ - methane.fs.unit.lagrange_mult[0.0, "O"] - ] = 2.730521354347429e-06 + methane.scaling_factor[methane.fs.unit.gibbs_minimization[0.0, "Vap", "O2"]] = ( + 9.653850829168712e-07 + ) + methane.scaling_factor[methane.fs.unit.lagrange_mult[0.0, "C"]] = ( + 3.915957066473961e-06 + ) + methane.scaling_factor[methane.fs.unit.lagrange_mult[0.0, "H"]] = ( + 5.55811764258496e-06 + ) + methane.scaling_factor[methane.fs.unit.lagrange_mult[0.0, "N"]] = ( + 4.318668616445236e-06 + ) + methane.scaling_factor[methane.fs.unit.lagrange_mult[0.0, "O"]] = ( + 2.730521354347429e-06 + ) scaling = TransformationFactory("core.scale_model") sm = scaling.create_using(methane, rename=False) diff --git a/idaes/models_extra/column_models/MEAsolvent_column.py b/idaes/models_extra/column_models/MEAsolvent_column.py index ff84e57863..548b37d11d 100644 --- a/idaes/models_extra/column_models/MEAsolvent_column.py +++ b/idaes/models_extra/column_models/MEAsolvent_column.py @@ -948,14 +948,14 @@ def calculate_scaling_factors_props(blk): ) for v in blk.liquid_phase.properties.values(): - for (p, j) in v.appr_to_true_species.keys(): + for p, j in v.appr_to_true_species.keys(): iscale.constraint_scaling_transform( v.appr_to_true_species[p, j], iscale.get_scaling_factor( v.flow_mol_phase_comp_true[p, j], default=1, warning=True ), ) - for (p, j) in v.true_mole_frac_constraint.keys(): + for p, j in v.true_mole_frac_constraint.keys(): iscale.constraint_scaling_transform( v.true_mole_frac_constraint[p, j], iscale.get_scaling_factor( diff --git a/idaes/models_extra/column_models/plate_heat_exchanger.py b/idaes/models_extra/column_models/plate_heat_exchanger.py index 15a52f6381..754d370c26 100644 --- a/idaes/models_extra/column_models/plate_heat_exchanger.py +++ b/idaes/models_extra/column_models/plate_heat_exchanger.py @@ -109,9 +109,9 @@ class PlateHeatExchangerData(HeatExchangerNTUData): CONFIG.hot_side.has_pressure_change = True CONFIG.hot_side.get("has_pressure_change").set_domain(In([True])) # pylint: disable-next=protected-access - CONFIG.hot_side.get( - "has_pressure_change" - )._description = "Pressure change term construction flag - must be True" + CONFIG.hot_side.get("has_pressure_change")._description = ( + "Pressure change term construction flag - must be True" + ) # pylint: disable-next=protected-access CONFIG.hot_side.get("has_pressure_change")._doc = ( "Plate Heat Exchanger model includes correlations for pressure drop " @@ -121,9 +121,9 @@ class PlateHeatExchangerData(HeatExchangerNTUData): CONFIG.cold_side.has_pressure_change = True CONFIG.cold_side.get("has_pressure_change").set_domain(In([True])) # pylint: disable-next=protected-access - CONFIG.cold_side.get( - "has_pressure_change" - )._description = "Pressure change term construction flag - must be True" + CONFIG.cold_side.get("has_pressure_change")._description = ( + "Pressure change term construction flag - must be True" + ) # pylint: disable-next=protected-access CONFIG.cold_side.get("has_pressure_change")._doc = ( "Plate Heat Exchanger model includes correlations for pressure drop " diff --git a/idaes/models_extra/column_models/properties/MEA_solvent.py b/idaes/models_extra/column_models/properties/MEA_solvent.py index 343e820a35..2fd56b6d5c 100644 --- a/idaes/models_extra/column_models/properties/MEA_solvent.py +++ b/idaes/models_extra/column_models/properties/MEA_solvent.py @@ -629,8 +629,7 @@ def return_expression(blk, phase): x = blk.mole_frac_phase_comp_apparent return ( - ((x["Liq", "H2O"] * K_H2O**-2 + x["Liq", "MEA"] * K_MEA**-2) ** -1) - ** 0.5 + ((x["Liq", "H2O"] * K_H2O**-2 + x["Liq", "MEA"] * K_MEA**-2) ** -1) ** 0.5 * pyunits.W / pyunits.m / pyunits.K diff --git a/idaes/models_extra/gas_solid_contactors/properties/methane_iron_OC_reduction/gas_phase_thermo.py b/idaes/models_extra/gas_solid_contactors/properties/methane_iron_OC_reduction/gas_phase_thermo.py index bf55a212fb..8c0e675dae 100644 --- a/idaes/models_extra/gas_solid_contactors/properties/methane_iron_OC_reduction/gas_phase_thermo.py +++ b/idaes/models_extra/gas_solid_contactors/properties/methane_iron_OC_reduction/gas_phase_thermo.py @@ -651,9 +651,7 @@ def _dens_mol(self): def ideal_gas(b): pressure = pyunits.convert(b.pressure, to_units=pyunits.Pa) temperature = pyunits.convert(b.temperature, to_units=pyunits.K) - dens_mol = pyunits.convert( - b.dens_mol, to_units=pyunits.mol / pyunits.m**3 - ) + dens_mol = pyunits.convert(b.dens_mol, to_units=pyunits.mol / pyunits.m**3) gas_constant = pyunits.convert( Constants.gas_constant, to_units=pyunits.J / pyunits.mol / pyunits.K ) diff --git a/idaes/models_extra/gas_solid_contactors/properties/oxygen_iron_OC_oxidation/gas_phase_thermo.py b/idaes/models_extra/gas_solid_contactors/properties/oxygen_iron_OC_oxidation/gas_phase_thermo.py index 347debcb1b..3129d92004 100644 --- a/idaes/models_extra/gas_solid_contactors/properties/oxygen_iron_OC_oxidation/gas_phase_thermo.py +++ b/idaes/models_extra/gas_solid_contactors/properties/oxygen_iron_OC_oxidation/gas_phase_thermo.py @@ -675,9 +675,7 @@ def _dens_mol(self): def ideal_gas(b): pressure = pyunits.convert(b.pressure, to_units=pyunits.Pa) temperature = pyunits.convert(b.temperature, to_units=pyunits.K) - dens_mol = pyunits.convert( - b.dens_mol, to_units=pyunits.mol / pyunits.m**3 - ) + dens_mol = pyunits.convert(b.dens_mol, to_units=pyunits.mol / pyunits.m**3) gas_constant = pyunits.convert( Constants.gas_constant, to_units=pyunits.J / pyunits.mol / pyunits.K ) diff --git a/idaes/models_extra/gas_solid_contactors/unit_models/bubbling_fluidized_bed.py b/idaes/models_extra/gas_solid_contactors/unit_models/bubbling_fluidized_bed.py index df67a9b723..bfed6430ae 100644 --- a/idaes/models_extra/gas_solid_contactors/unit_models/bubbling_fluidized_bed.py +++ b/idaes/models_extra/gas_solid_contactors/unit_models/bubbling_fluidized_bed.py @@ -560,9 +560,9 @@ def build(self): tmp_dict = dict(**self.config.solid_phase_config.reaction_package_args) tmp_dict["gas_state_block"] = self.gas_emulsion.properties tmp_dict["solid_state_block"] = self.solid_emulsion.properties - tmp_dict[ - "has_equilibrium" - ] = self.config.solid_phase_config.has_equilibrium_reactions + tmp_dict["has_equilibrium"] = ( + self.config.solid_phase_config.has_equilibrium_reactions + ) tmp_dict["parameters"] = self.config.solid_phase_config.reaction_package self.solid_emulsion.reactions = ( self.config.solid_phase_config.reaction_package.reaction_block_class( diff --git a/idaes/models_extra/gas_solid_contactors/unit_models/moving_bed.py b/idaes/models_extra/gas_solid_contactors/unit_models/moving_bed.py index d6b532d096..2939d54f0b 100644 --- a/idaes/models_extra/gas_solid_contactors/unit_models/moving_bed.py +++ b/idaes/models_extra/gas_solid_contactors/unit_models/moving_bed.py @@ -639,9 +639,9 @@ def build(self): tmp_dict = dict(**self.config.solid_phase_config.reaction_package_args) tmp_dict["gas_state_block"] = self.gas_phase.properties tmp_dict["solid_state_block"] = self.solid_phase.properties - tmp_dict[ - "has_equilibrium" - ] = self.config.solid_phase_config.has_equilibrium_reactions + tmp_dict["has_equilibrium"] = ( + self.config.solid_phase_config.has_equilibrium_reactions + ) tmp_dict["parameters"] = self.config.solid_phase_config.reaction_package self.solid_phase.reactions = ( self.config.solid_phase_config.reaction_package.reaction_block_class( diff --git a/idaes/models_extra/power_generation/costing/generic_ccs_capcost_custom_dict.py b/idaes/models_extra/power_generation/costing/generic_ccs_capcost_custom_dict.py index 522410cf9b..ee45f0ad5b 100644 --- a/idaes/models_extra/power_generation/costing/generic_ccs_capcost_custom_dict.py +++ b/idaes/models_extra/power_generation/costing/generic_ccs_capcost_custom_dict.py @@ -19,7 +19,6 @@ def load_generic_ccs_costing_dictionary(path=None): - """ Custom dictionaries have been added as a way to add new scaling equations that are not based on the Bituminous Baseline report. @@ -669,9 +668,9 @@ def load_generic_ccs_costing_dictionary(path=None): for accountkey in generic_ccs_costing_exponents[tech][ account ].keys(): # get one " exponents"account property at a time - accounts_dict[account][ - accountkey - ] = generic_ccs_costing_exponents[tech][account][accountkey] + accounts_dict[account][accountkey] = ( + generic_ccs_costing_exponents[tech][account][accountkey] + ) sorted_accountkeys = sorted( accounts_dict[account] ) # now, sort the accountkeys alphabetically within each account @@ -679,9 +678,9 @@ def load_generic_ccs_costing_dictionary(path=None): key: accounts_dict[account][key] for key in sorted_accountkeys } # re-add the keys in alphabetical order - gccsd[ - ccs - ] = accounts_dict # use the alias to update the original dictionary + gccsd[ccs] = ( + accounts_dict # use the alias to update the original dictionary + ) with open( os.path.join(directory, "generic_ccs_costing_data.json"), "w" diff --git a/idaes/models_extra/power_generation/flowsheets/subcritical_power_plant/subcritical_power_plant.py b/idaes/models_extra/power_generation/flowsheets/subcritical_power_plant/subcritical_power_plant.py index 65bdd508fa..287cfe47ab 100644 --- a/idaes/models_extra/power_generation/flowsheets/subcritical_power_plant/subcritical_power_plant.py +++ b/idaes/models_extra/power_generation/flowsheets/subcritical_power_plant/subcritical_power_plant.py @@ -589,9 +589,9 @@ def main_dynamic(): m_dyn.fs_main.turbine_master_ctrl.mv_ref.value = ( m_ss.fs_main.fs_stc.turb.throttle_valve[1].valve_opening[t0].value ) - m_dyn.fs_main.turbine_master_ctrl.setpoint[ - : - ].value = m_ss.fs_main.fs_stc.power_output[t0].value + m_dyn.fs_main.turbine_master_ctrl.setpoint[:].value = ( + m_ss.fs_main.fs_stc.power_output[t0].value + ) m_dyn.fs_main.boiler_master_ctrl.mv_ref.value = ( m_ss.fs_main.fs_blr.aBoiler.flowrate_coal_raw[t0].value ) @@ -2212,16 +2212,16 @@ def print_pfd_results(m): tag_formats = {} for i, s in sd.items(): tags[i + "_Fmass"] = s.flow_mass - tag_formats[i + "_Fmass"] = ( - lambda x: "{:.1f} kg/s" if x >= 10 else "{:.2f} kg/s" + tag_formats[i + "_Fmass"] = lambda x: ( + "{:.1f} kg/s" if x >= 10 else "{:.2f} kg/s" ) tags[i + "_F"] = s.flow_mol tag_formats[i + "_F"] = "{:,.0f} mol/s" tags[i + "_T"] = s.temperature tag_formats[i + "_T"] = "{:,.0f} K" tags[i + "_P_kPa"] = s.pressure / 1000 - tag_formats[i + "_P_kPa"] = ( - lambda x: "{:,.0f} kPa" if x >= 100 else "{:.2f} kPa" + tag_formats[i + "_P_kPa"] = lambda x: ( + "{:,.0f} kPa" if x >= 100 else "{:.2f} kPa" ) tags[i + "_P"] = s.pressure / 1000 tag_formats[i + "_P"] = "{:,.0f} Pa" diff --git a/idaes/models_extra/power_generation/properties/natural_gas_PR.py b/idaes/models_extra/power_generation/properties/natural_gas_PR.py index c137609c4a..8c2a71a4d1 100644 --- a/idaes/models_extra/power_generation/properties/natural_gas_PR.py +++ b/idaes/models_extra/power_generation/properties/natural_gas_PR.py @@ -532,6 +532,7 @@ class EosType(enum.Enum): _water_visc_d = {"Vap": ChapmanEnskogLennardJones, "Liq": None} _water_therm_cond = {"Vap": Eucken, "Liq": None} + # returns a configuration dictionary for the list of specified components def get_prop(components=None, phases="Vap", eos=EosType.PR, scaled=False): if components is None: diff --git a/idaes/models_extra/power_generation/unit_models/boiler_fireside.py b/idaes/models_extra/power_generation/unit_models/boiler_fireside.py index f8cbe4e79f..2f016aed85 100644 --- a/idaes/models_extra/power_generation/unit_models/boiler_fireside.py +++ b/idaes/models_extra/power_generation/unit_models/boiler_fireside.py @@ -1018,7 +1018,7 @@ def flow_mass_flyash(b, t): return b.flowrate_daf_flyash[t] + b.flowrate_ash[t] def _make_momentum_balance(self): - # flue gas pressure is secondary air presure + # flue gas pressure is secondary air pressure # - pressure drop through windbox # and burner secondary air register @self.Constraint(self.flowsheet().time, doc="Flue gas pressure in Pascals") diff --git a/idaes/models_extra/power_generation/unit_models/boiler_heat_exchanger.py b/idaes/models_extra/power_generation/unit_models/boiler_heat_exchanger.py index 9753a89bc9..75c346fd80 100644 --- a/idaes/models_extra/power_generation/unit_models/boiler_heat_exchanger.py +++ b/idaes/models_extra/power_generation/unit_models/boiler_heat_exchanger.py @@ -289,6 +289,7 @@ def pitch_y_to_do(b): if self.config.has_holdup is True: add_object_reference(self, "volume_cold_side", self.cold_side.volume) add_object_reference(self, "volume_hot_side", self.hot_side.volume) + # Total tube side valume def volume_cold_side_eqn(b): return b.volume_cold_side == ( diff --git a/idaes/models_extra/power_generation/unit_models/boiler_heat_exchanger_2D.py b/idaes/models_extra/power_generation/unit_models/boiler_heat_exchanger_2D.py index bda0dd9195..c7c14329bb 100644 --- a/idaes/models_extra/power_generation/unit_models/boiler_heat_exchanger_2D.py +++ b/idaes/models_extra/power_generation/unit_models/boiler_heat_exchanger_2D.py @@ -2536,10 +2536,7 @@ def mech_sigma_theta_header(b, t, r): ) * b.head_ri**2 * b.head_ro**2 - / ( - (r * b.head_ri_scaling) ** 2 - * (b.head_ro**2 - b.head_ri**2) - ) + / ((r * b.head_ri_scaling) ** 2 * (b.head_ro**2 - b.head_ri**2)) ) ) @@ -2869,7 +2866,7 @@ def sigma_eff_P2(b, t): # rupture time calculation at crotch corner @self.Expression( - self.flowsheet().time, doc="Rupture Tme at Crotch Corner for Header" + self.flowsheet().time, doc="Rupture Time at Crotch Corner for Header" ) def rupture_time_crotch_corner(b, t): if value(b.sigma_eff_P1[t]) > 10: # MPa diff --git a/idaes/models_extra/power_generation/unit_models/helm/turbine_multistage.py b/idaes/models_extra/power_generation/unit_models/helm/turbine_multistage.py index 92e34d7d3b..52b2500730 100644 --- a/idaes/models_extra/power_generation/unit_models/helm/turbine_multistage.py +++ b/idaes/models_extra/power_generation/unit_models/helm/turbine_multistage.py @@ -266,9 +266,9 @@ def build(self): thrtl_cfg = unit_cfg.copy() thrtl_cfg["valve_function"] = self.config.throttle_valve_function - thrtl_cfg[ - "valve_function_callback" - ] = self.config.throttle_valve_function_callback + thrtl_cfg["valve_function_callback"] = ( + self.config.throttle_valve_function_callback + ) # Adding unit models # ------------------------ @@ -762,9 +762,9 @@ def initialize_build( break if it_count < flow_iterate - 1: for t in self.inlet_split.inlet.flow_mol: - self.inlet_split.inlet.flow_mol[ - t - ].value = self.outlet_stage.inlet.flow_mol[t].value + self.inlet_split.inlet.flow_mol[t].value = ( + self.outlet_stage.inlet.flow_mol[t].value + ) for s in self.hp_split.values(): for i, o in enumerate(s.outlet_list): diff --git a/idaes/models_extra/power_generation/unit_models/soc_submodels/common.py b/idaes/models_extra/power_generation/unit_models/soc_submodels/common.py index 4dc4fb66d5..af587915a4 100644 --- a/idaes/models_extra/power_generation/unit_models/soc_submodels/common.py +++ b/idaes/models_extra/power_generation/unit_models/soc_submodels/common.py @@ -514,9 +514,7 @@ def _binary_diffusion_coefficient_expr(temperature, p, c1, c2): f = 1.52996 g = 1.76474 h = 3.89411 - omega = ( - a / tr**b + c / pyo.exp(d * tr) + e / pyo.exp(f * tr) + g / pyo.exp(h * tr) - ) + omega = a / tr**b + c / pyo.exp(d * tr) + e / pyo.exp(f * tr) + g / pyo.exp(h * tr) cm2_to_m2 = 0.01 * 0.01 Pa_to_bar = 1e-5 return ( diff --git a/idaes/models_extra/power_generation/unit_models/soc_submodels/solid_oxide_cell.py b/idaes/models_extra/power_generation/unit_models/soc_submodels/solid_oxide_cell.py index 057e8cb724..fb569fab3f 100644 --- a/idaes/models_extra/power_generation/unit_models/soc_submodels/solid_oxide_cell.py +++ b/idaes/models_extra/power_generation/unit_models/soc_submodels/solid_oxide_cell.py @@ -238,7 +238,7 @@ class SolidOxideCellData(UnitModelBlockData): domain=common._SubsetOf(_gas_species_list), default=None, description="List of fuel-side species that do not participate in " - "reactions at the triple phase boundary." + "reactions at the triple phase boundary.", # But may be involved in reforming ), ) @@ -767,15 +767,13 @@ def interconnect_temperature_continuity_eqn(b, t, iz): @self.Constraint(tset, iznodes) def no_heat_flux_fuel_interconnect_eqn(b, t, iz): return ( - 0 * pyo.units.W / pyo.units.m**2 - == interconnect_heat_flux_x1[t, iz] + 0 * pyo.units.W / pyo.units.m**2 == interconnect_heat_flux_x1[t, iz] ) @self.Constraint(tset, iznodes) def no_heat_flux_oxygen_interconnect_eqn(b, t, iz): return ( - 0 * pyo.units.W / pyo.units.m**2 - == interconnect_heat_flux_x0[t, iz] + 0 * pyo.units.W / pyo.units.m**2 == interconnect_heat_flux_x0[t, iz] ) @self.Constraint(tset, iznodes) @@ -986,10 +984,11 @@ def initialize_build( ) ) for j in self.fuel_triple_phase_boundary.component_list: - self.fuel_triple_phase_boundary.mole_frac_comp[ - t, iz, j - ].value = pyo.value( - self.fuel_triple_phase_boundary.conc_mol_comp[t, iz, j] / denom + self.fuel_triple_phase_boundary.mole_frac_comp[t, iz, j].value = ( + pyo.value( + self.fuel_triple_phase_boundary.conc_mol_comp[t, iz, j] + / denom + ) ) if j in self.fuel_triple_phase_boundary.reacting_gas_list: self.fuel_triple_phase_boundary.log_mole_frac_comp[ @@ -1020,11 +1019,11 @@ def initialize_build( ) ) for j in self.oxygen_triple_phase_boundary.component_list: - self.oxygen_triple_phase_boundary.mole_frac_comp[ - t, iz, j - ].value = pyo.value( - self.oxygen_triple_phase_boundary.conc_mol_comp[t, iz, j] - / denom + self.oxygen_triple_phase_boundary.mole_frac_comp[t, iz, j].value = ( + pyo.value( + self.oxygen_triple_phase_boundary.conc_mol_comp[t, iz, j] + / denom + ) ) if j in self.oxygen_triple_phase_boundary.reacting_gas_list: self.oxygen_triple_phase_boundary.log_mole_frac_comp[ diff --git a/idaes/models_extra/power_generation/unit_models/waterwall_section.py b/idaes/models_extra/power_generation/unit_models/waterwall_section.py index d0ccfb93f2..6cb947efc3 100644 --- a/idaes/models_extra/power_generation/unit_models/waterwall_section.py +++ b/idaes/models_extra/power_generation/unit_models/waterwall_section.py @@ -429,11 +429,7 @@ def area_cross_slag(b, t): def volume_eqn(b, t): return ( b.volume[t] - == 0.25 - * const.pi - * b.tube_diameter**2 - * b.tube_length - * b.number_tubes + == 0.25 * const.pi * b.tube_diameter**2 * b.tube_length * b.number_tubes ) def _make_performance(self): diff --git a/idaes/models_extra/temperature_swing_adsorption/fixed_bed_tsa0d.py b/idaes/models_extra/temperature_swing_adsorption/fixed_bed_tsa0d.py index 62f0a22a8b..77da5f6105 100644 --- a/idaes/models_extra/temperature_swing_adsorption/fixed_bed_tsa0d.py +++ b/idaes/models_extra/temperature_swing_adsorption/fixed_bed_tsa0d.py @@ -522,10 +522,7 @@ def Reynolds_mf(b): @self.Constraint(doc="Kunii and Levenspiel equation") def velocity_mf_eq(b): return ( - 1.75 - / b.particle_sphericity - / b.bed_voidage_mf**3 - * b.Reynolds_mf**2 + 1.75 / b.particle_sphericity / b.bed_voidage_mf**3 * b.Reynolds_mf**2 + 150 * (1 - b.bed_voidage_mf) / b.particle_sphericity**2 @@ -2802,29 +2799,29 @@ def get_var_dict(self): var_dict["Pressure drop [Pa]"] = -self.pressure_drop var_dict["Number of beds"] = self.number_beds - var_dict[ - "CO2 captured in one cycle per bed [kg/cycle]" - ] = self.CO2_captured_bed_cycle + var_dict["CO2 captured in one cycle per bed [kg/cycle]"] = ( + self.CO2_captured_bed_cycle + ) var_dict["Cycles per year"] = self.cycles_year - var_dict[ - "Total CO2 captured per year [tonne/year]" - ] = self.total_CO2_captured_year + var_dict["Total CO2 captured per year [tonne/year]"] = ( + self.total_CO2_captured_year + ) - var_dict[ - "Amount of flue gas processed per year [Gmol/year]" - ] = self.flue_gas_processed_year + var_dict["Amount of flue gas processed per year [Gmol/year]"] = ( + self.flue_gas_processed_year + ) - var_dict[ - "Amount of flue gas processed per year (target) [Gmol/year]" - ] = self.flue_gas_processed_year_target + var_dict["Amount of flue gas processed per year (target) [Gmol/year]"] = ( + self.flue_gas_processed_year_target + ) var_dict["Amount of CO2 to atmosphere [mol/s]"] = self.emissions_co2 - var_dict[ - "Concentration of CO2 emitted to atmosphere [ppm]" - ] = self.emissions_co2_ppm + var_dict["Concentration of CO2 emitted to atmosphere [ppm]"] = ( + self.emissions_co2_ppm + ) return var_dict diff --git a/requirements-dev.txt b/requirements-dev.txt index e2ed7646e2..384dee177e 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -16,12 +16,11 @@ sphinx-copybutton==0.5.2 pytest coverage pytest-cov -black>=22.1.0 # @lbianchi-lbl: both pylint and astroid should be tightly pinned; see .pylint/idaes_transform.py for more info pylint==3.0.3 astroid==3.0.3 flake8 -black==22.3.0 +black==24.3.0 # pre-commit install, manage, and run pre-commit hooks pre-commit