11. API reference
11.1. Optimization
A function is present to evaluate if the input dictionary is properly characterized.
This function evaluates if the items in the input dictionary are properly characterized. |
The main function that initiates the optimization procedure.
|
This function runs the optimization pipeline. |
In this function, the starting samples are created.
Check if previously generated results exists in the provided results directory. |
|
Scales the starting sample to the given design space. |
|
Writes the starting samples to file. |
|
Load the starting samples for the optimization run. |
In addition, the name of the optimization class is loaded.
Parse all available optimizers. |
|
|
Load the selected optimizer. |
Returns the names of the available genetic optimizers. |
|
Returns the optimizer fuction object |
Finally, an object from the optimization class is instantiated
and the run_optimizer() is called.
The NSGA-II optimization class includes methods to perform NSGA-II.
|
The NSGAII class includes methods to perform a deterministic and robust optimization using NSGA-II optimizer. |
Run one iteration of the NSGA-II optimizer. |
|
Run an optimization using the NSGA-II algorithm. |
The methods to create and evaluate the samples.
|
Defines the set of samples considered for evaluation. |
|
Evaluation of the set of samples. |
|
Assigns the calulated fitness to the corresponding samples. |
Read in the design of experiment. |
|
Evaluation of the Design Of Experiments (DoE). |
The methods to create and update the result files.
Initialization of the results directory and writing of the column names in the STATUS file. |
|
This method extracts the current generation number and the number of model evaluations performed. |
|
A message is appended to the STATUS file. |
|
|
This function is used to append the result (population or fitness) to the corresponding file. |
11.2. Uncertainty Quantification
The main function that initiates the uncertainty quantification procedure.
This function is the main to run uncertainty quantification. |
This function instantiates an object from Data. This class includes
methods to acquire the characteristics of the stochastic parameters and to create
the file where the samples are stored
|
The class includes methods to create a file to store the samples and to store information on the stochastic design space, exctracted from the |
Creating the file that saved the input samples and model outputs. |
|
Read in the stochastic design space and save the information in a dictionary |
An object from the class RandomExperiment is instantiated. This class
includes a method to determine the number of samples required to construct the PCE.
|
RandomExperiment objects include information on the random samples, such as dimension, scaled and unscaled values. |
This method sets the number of samples to 2*(p+n)!/p!n!, i.e the number of terms in the full PC expansion of order p in n random variables. |
In addition, methods to create the distributions, generate the samples and evaluate the samples are present.
Read the previously evaluated samples and store them for future PCE construction. |
|
Create the distributions, polynomial distributions and polynomial types based on the stochastic design space. |
|
Generate the samples for model evaluations. |
|
Add the generated samples to the samples file. |
|
Evaluate the samples in the model and store the samples and outputs in the samples file. |
The PCE class enables to construct a PCE.
|
Class which creates a Polynomial Chaos Expansion (PCE) object. |
This function creates a list of all possible vectors of length 'n' that sum to 's' |
|
This method returns a set of multi-indices |
|
|
Perform Ordinary Least Squares on the input matrices a_matrix and b_matrix. |
|
This method builds the matrix containing the basis functions evaluated at sample locations, i.e. the matrix A in Au = b. |
Solve Ordinary Least Squares problem Full PC expansion is assumed containing n_terms(dimension,order) |
The statistics, Sobol’ indices and Leave-One-Out error are extracted out of the PCE in the methods below.
|
This function calculates high order moments (up to order 2) by taking advantage of the fact that any permutation of indices will lead to the same value for the summand. |
Calculate the term <psii,psij> |
|
This method calculates the Sobol' indices Si of PCE. |
|
This method evaluates the Leave-One-Out (LOO) error for the constructed PCE. |
Finally, the results are printed and stored in corresponding result files.
This method prints an overview of the inputs and results of the PCE. |
|
|
This module creates the probability density function and cumulative distribution function and writes the corresponding values to construct these values in the result files. |
To screen the design space (i.e. generate a PCE for a set of design samples),
the following functions allows to retrieve the bounds for the design variables,
to determine the design samples and to generate design_space files
to store the input for the different design samples to be evaluated.
|
This function loads the design variable names and bounds out of the |
Based on the design variable characteristics, a set of design samples is created through Latin Hypercube Sampling. |
|
A new design space file is created. |
11.3. Post-processing
The optimization results are extracted with the methods in PostProcessOpt.
The PostProcessOpt class provides methods to retrieve the fitness and population for the generations provided during the optimization. |
|
|
Determines the number of design samples in the population and the number of generations performed. |
|
Returns the fitness values for the population generated in the specified generation. |
|
Returns the fitness values for the population generated in the specified generation. |
|
Generates the files that include the sorted population and fitness files. |
|
Returns the population and corresponding fitness values for the generation of interest. |
The uncertainty quantification results are extracted with the methods in PostProcessUQ.
The PostProcessUQ class provides methods to retrieve the LOO error, plot the Sobol indices, PDF and CDF. |
|
|
Reads the file with information on the cumulative density function or probability density function. |
|
Retrieves the information on the Sobol' indices from the corresponding file in the result directory. |
Retrieves the points that define the probability density function. |
|
Retrieves the points that define the cumulative density function. |
|
Reads the Leave-One-Out error from the corresponding file in the result directory. |
|
|
This method gathers the Sobol' indices for each stochastic parameter for each sample. |
11.4. Characterization of design space and stochastic space
In StochasticDesignSpace, methods are present to retrieve the information
on the design space and stochastic space for the specific case.
|
Class which creates an object which characterizes the stochastic design space for the system model evaluation. |
|
Reads the |
|
Reads the |
In addition, a method is present to attach the objectives to the case, as well as a method to convert the input sample into a dictionary.
|
Attaches the objectives of the configured optimization run. |
|
Convert the input sample for model evaluation into a dictionary. |
11.5. The cases
The case of interest is loaded in the load_case() function.
For the selected case, the design variables and model parameters are loaded based on information from |
11.5.2. Power-to-fuel
A wrapper function is present to evaluate the power-to-fuel model with the samples generated by the optimization or uncertainty quantification algorithm. In addition, a function is present to read in the fixed data, required for each model evaluation.
Evaluation of the system objectives for one given design. |
|
Set the fixed parameters for each model evaluation. |
The power-to-fuel model contains a class which creates an object that stores information on the required data.
This class enables to read data from the data files. |
|
This method loads the hourly solar irradiance data and ambient temperature data, situated in the 'sol_irr' and 'T_amb' columns of the climate data file. |
|
This method loads the deterministic values of the model parameters, defined in the design_space file. |
In the Evaluation class, methods are present to quantify the
photovoltaic array power.
This class evaluates the photovoltaic-electrolyzer system. |
|
Quantify the maximum power of the photovoltaic array for a given solar irradiance and ambient temperature. |
|
The hourly photovoltaic power is quantified via the PVlib package. |
In addition, methods are present to characterize the PEM electrolyzer array operation
The electrolyzer model, based on the work of Saeed et al. [1]. |
|
|
When current is provided, this function determines the corresponding hydrogen mass flow rate per hour. |
The electrolyzer stack is evaluated over a range of input currents. |
|
|
For a given power supplied to the electrolyzer, this function determines the actual hydrogen produced. |
The evaluation() method includes the power management strategy.
This is the main method of the Evaluation class. |
After applying the power management strategy, the component lifetimes and the system costs are quantified, concluded by a method to print the results.
The lifetime method determines the lifetime of the electrolyzer array, based on the number of operating hours during the evaluated year. |
|
Based on the capital recovery factor, the CAPEX, OPEX and replacement cost of the system components, the levelized cost of hydrogen is determined. |
|
This method prints the levelized cost of hydrogen, the hydrogen production, the annual energy produced by the photovoltaic array and the energy consumed by the electrolyzer array. |
11.5.3. Power-to-power
A wrapper function is present to evaluate the power-to-power model with the samples generated by the optimization or uncertainty quantification algorithm. In addition, a function is present to read in the fixed data, required for each model evaluation.
Evaluation of the system objectives for one given design. |
|
Set the fixed parameters for each model evaluation. |
The power-to-power model contains a class which creates an object that stores information on the required data.
This class enables to read data from the data files. |
|
This method loads the hourly solar irradiance data and ambient temperature data, situated in the 'sol_irr' and 'T_amb' columns of the climate data file. |
|
This method loads the hourly electricity demand data, situated in the 'total electricity' column of the demand data file. |
|
This method loads the deterministic values of the model parameters, defined in the design_space file. |
In the Evaluation class, methods are present to generate
the electricity price profiles and to quantify the
photovoltaic array power.
This class evaluates the photovoltaic-hydrogen system. |
|
Set the grid electricity price for buying and selling electricity. |
|
Quantify the maximum power of the photovoltaic array for a given solar irradiance and ambient temperature. |
|
The hourly photovoltaic power is quantified via the PVlib package. |
|
Determine the hourly net power. |
In addition, methods are present to characterize the PEM electrolyzer array operation
The electrolyzer model, based on the work of Saeed et al. [1]. |
|
|
When current is provided, this function determines the corresponding hydrogen mass flow rate per hour. |
The electrolyzer stack is evaluated over a range of input currents. |
|
|
For a given power supplied to the electrolyzer, this function determines the actual hydrogen produced. |
The fuel cell array.
The PEM fuel cell model, based on the work of Murugesan et al. [2]. |
|
The fuel cell stack is evaluated over a range of input currents. |
|
|
This method evaluates if the power required from the fuel cell lies within the operating range of the DC-DC converter and of the fuel cell array. |
The evaluation() method includes the power management strategy.
This is the main method of the Evaluation class. |
After applying the power management strategy, the component lifetimes, self sufficiency ratio and system costs are quantified, concluded by a method to print the results.
The lifetime method determines the lifetime of the electrolyzer array and fuel cell array, based on the number of operating hours for each component during the evaluated period. |
|
|
The self-sufficiency ratio is quantified. |
Based on the capital recovery factor, the CAPEX, OPEX and replacement cost of the system components, the levelized cost of electricity is determined. |
|
This method prints the levelized cost of electricity, the self-sufficiency ratio and the annual energy produced by the photovoltaic array. |
11.5.4. Power-to-mobility
A wrapper function is present to evaluate the power-to-mobility model with the samples generated by the optimization or uncertainty quantification algorithm. In addition, a function is present to read in the fixed data, required for each model evaluation.
Evaluation of the system objectives for one given design. |
|
Set the fixed parameters for each model evaluation. |
The power-to-power model contains a class which creates an object that stores information on the required data.
This class enables to read data from the data files. |
|
This method loads the hourly solar irradiance data and ambient temperature data, situated in the 'sol_irr' and 'T_amb' columns of the climate data file. |
|
|
This method loads the deterministic values of the model parameters, defined in the design_space file. |
In the Evaluation class, methods are present to generate
the demand profiles and to quantify the photovoltaic array power.
This class evaluates the power-to-mobility system. |
|
|
Set the grid electricity price for buying and selling electricity. |
|
Quantify the maximum power of the photovoltaic array for a given solar irradiance and ambient temperature. |
|
The hourly photovoltaic power is quantified via the PVlib package. |
In addition, methods are present to characterize the PEM electrolyzer array operation
|
The electrolyzer model, based on the work of Saeed et al. [2]. |
|
When current is provided, this function determines the corresponding hydrogen mass flow rate per hour. |
|
The electrolyzer stack is evaluated over a range of input currents. |
|
When the hydrogen mass flow rate is provided, this function determines the corresponding required power per hour. |
The compressor module.
|
The compressor module defined the required compression power to compress the hydrogen mass flow rate [3]. |
|
The power consumption by the electrolyzer stack and compressor are evaluated over a range of hydrogen mass flow rates. |
The hydrogen tank and dispenser module.
The maximum storage capacity of the hydrogen tank. |
The power management strategy module.
|
When a hydrogen demand is provided, this method determines the power to generate the hydrogen in the electrolyzer array and the power to compress the hydrogen in the compressor. |
|
When there is power available to produce hydrogen, this method distributes this power over the electrolyzer array and compressor, such that the hydrogen is produced and compressed with this given power. |
|
Extract the hydrogen demand from the storage tank. |
The evaluation() method evaluates the power management strategy.
This is the main method of the Evaluation class. |
After applying the power management strategy, the component lifetimes, system costs and carbon intensity are quantified, concluded by a method to print the results.
The lifetime method determines the lifetime of the electrolyzer array, based on the number of operating hours during the evaluated year. |
|
Based on the capital recovery factor, the CAPEX, OPEX and replacement cost of the system components, the levelized cost of mobility [euro/km] is determined. |
|
The life cycle assessment is performed based on the CO2 emissions from constructing the system components and the emissions related to consuming grid electricity and diesel. |
|
|
This method prints the levelized cost of electricity, the self-sufficiency ratio and the annual energy produced by the photovoltaic array. |
11.5.5. Four-bar truss
A wrapper function is present to evaluate the four-bar truss model with the samples generated by the optimization or uncertainty quantification algorithm.
Evaluation of the system objectives for one given design. |
The four-bar truss model is present in the four_bar_truss module.
|
This function evaluates the volume and displacement of a four-bar truss system. |
11.5.6. EnergyPLAN
An evaluate function is present to evaluate the EnergyPLAN Python wrapper with the samples generated by the optimization or uncertainty quantification algorithm.
Evaluation of the system objectives for one given design. |
The Python wrapper for the EnergyPLAN model contains functions to create the input text file, read out the output text file and to run the command which executes the EnergyPLAN executable file.
This function generates a new input file, evaluates this input file in the EnergyPLAN model and reads the values for the quantities of interest from the generated output file. |
|
|
This function writes a new input file for the EnergyPLAN model. |
This function reads the output file, generated by the EnergyPLAN model. |