turboflow.axial_turbine.design_optimization module

class turboflow.axial_turbine.design_optimization.BlackBoxOptimization[source]

Bases: object

Methods

export_optimization_process

find_champion

print_optimization_process

update_optimization_process

export_optimization_process(config)[source]
find_champion(solver)[source]
print_optimization_process()[source]
update_optimization_process(results, converged=True, f=None, violation=None, solver=None)[source]
class turboflow.axial_turbine.design_optimization.CascadesOptimizationProblem(config)[source]

Bases: OptimizationProblem

A class representing a turbine design optimization problem.

This class is designed for solving design optimization problems of axial turbines. It is initialized by providing a dictionary containing information on design variables, objective function, constraints and bounds.

Parameters:
configdictionary

A dictionary containing necessary configuration options for computing optimal turbine.

Attributes:
fluidFluidCoolProp_2Phase

An instance of the FluidCoolProp_2Phase class representing the fluid properties.

resultsdict

A dictionary to store results.

boundary_conditionsdict

A dictionary containing boundary condition data.

geometrydict

A dictionary containing geometry-related data.

model_optionsdict

A dictionary containing options related to the analysis model.

reference_valuesdict

A dictionary containing reference values for calculations.

design_variables_keyslist

A list of strings defining the selected design variables.

objective_functionstr

A string defining the selected objective function for the design optimization problem.

eq_constraintslist

A list of strings containing the selected equaility constraints for the design optimization problem.

ineq_constraintslist

A list of strings containing the selected inequaility constraints for the design optimization problem.

boundslist

A list of tuples on the form (lower bound, upper bound) defining the bounds for the design optimization problem.

radius_typestr

A string deciding what type of turbine geometry should be condidered (constant mean, hub or tip radius).

vars_scaleddict

A dict containing the scaled flow design variables used to evaluate turbine performance.

Methods

fitness(x)

Evaluate the objective function and constraints at a given point x.

get_bounds()

Provide the bounds for the design optimization problem.

get_n_eq()

Get the number of equality constraints.

get_n_ineq()

Get the number of oinequality constraints.

get_omega(specific_speed, mass_flow, h0_in, d_is, h_is)

Convert specific speed to actual angular speed

index_variables(variables)

Convert a dict containing lists or arrays to a dictionaries of only one element.

get_given_bounds(design_variable)

Retrieves the lower and upper bounds for the given design variables.

get_constraints(self, constraints):

Converts a list of constraints to equality and inequality constraints.

update_boundary_conditions(design_point)

Update the boundary conditions of the turbine analysis problem with the design point of the design optimization problem.

convert_performance_analysis_results(performance_problem)

Generate a feasable set of initial guess from a solved performance analysis problem object.

evaluate_constraints:

Evaluate constraints

get_objective_function:

Change scale for the objective function depending on its type.

get_nested_value:

Get values from a dictionary of Dataframes

convert_performance_analysis_results(performance_problem)[source]

Generate a feasable set of initial guess from a solved performance analysis problem object.

The function adopt the vars_scaled attribute from the solved performance analysis problem, the geometry and angular speed to generate an initial guess of correct form to be given to the design optimization problem.

Returns:
dict

Feasable initial guess.

evaluate_constraints(constraints_list)[source]

Evaluate constraints.

This function evaluates the constraints from the information in constraints_list. Constraints are defined to be less than 0.

constraints_list is a list of dictionaries, where each dictionary have a variable, scale and value key.

Parameters:
constraints_listlist

List of dictionaries with constraint information

Returns:
numpy.ndarray

Array with constraint values

fitness(x)[source]

Evaluate the objective function and constraints for given decision variables.

Parameters:
xarray-like

Vector of independent variables (i.e., degrees of freedom).

Returns:
array_like

Vector containing the objective function, equality constraints, and inequality constraints.

fitness_black_box_constrained(x)[source]

Evaluate the objective function and constraints at a given pint x for genetic algrothims.

Parameters:
xarray-like

Vector of design variables.

Returns:
numpy.ndarray

An array containg the value of the objective function and constraints.

fitness_gradient_based(x)[source]

Evaluate the objective function and constraints at a given pint x.

Parameters:
xarray-like

Vector of design variables.

Returns:
numpy.ndarray

An array containg the value of the objective function and constraints.

fitness_gradient_free(x)[source]

Evaluate the objective function and constraints at a given pint x for genetic algrothims.

Parameters:
xarray-like

Vector of design variables.

Returns:
numpy.ndarray

An array containg the value of the objective function and constraints.

get_bounds()[source]

Provide the bounds for the design optimization problem.

Returns:
list

List of toutples containg the lower and upper bound for each design variable.

get_constraints(constraints)[source]

Converts a list of constraints to equality and inequality constraints.

Parameters:
constraintslist of dict

List of constraints where each constraint is represented as a dictionary with keys “type”, “variable”, “value”, and “normalize”. “type” represents the type of constraint (‘=’, ‘<’, or ‘>’). “variable” is the variable involved in the constraint. “value” is the value of the constraint. “normalize” specifies whether to normalize the constraint value.

Returns:
list of dict

List of equality constraints, each represented as a dictionary with keys “variable”, “value”, and “scale”. “variable” is the variable involved in the constraint. “value” is the value of the constraint. “scale” is the scaling factor applied to the value.

list of dict

List of inequality constraints, each represented as a dictionary with keys “variable”, “value”, and “scale”. “variable” is the variable involved in the constraint. “value” is the value of the constraint. “scale” is the scaling factor applied to the value.

get_given_bounds(design_variables)[source]

Retrieves the lower and upper bounds for the given design variables.

Parameters:
design_variablesdict

A dictionary where each key maps to a dictionary containing a “value” key, a “lower_bound” key, and an “upper_bound” key. The values can be a list, numpy array, or float.

Returns:
lblist

A list of lower bounds for the design variables.

ublist

A list of upper bounds for the design variables.

get_nec()[source]

Get the number of equality constraints.

Returns:
int

Number of equality constraints.

get_nested_value(d, path)[source]

Get values from a dictionary of Dataframes. Path is on the form dataframe.column, and returns d[dataframe][column]

Parameters:
ddict

Dictionary of DataFrames

pathstr

String giving the path of the DataFrame values

Returns:
numpy.ndarray

Array of specified values

get_nic()[source]

Get the number of inequality constraints.

Returns:
int

Number of inequality constraints.

get_objective_function(objective)[source]

Change scale for the objective function depending on its type. If objective function should be maximized, the sign of the scale is changed.

Parameters:
objectivedict

dictionary containing variable name, type and scale of the objective function.

Returns:
dict

dictionary containing modified scale of the objective function

get_omega(specific_speed, mass_flow, h0_in, d_is, h_is)[source]

Convert specific speed to actual angular speed

Parameters:
specific_speedfloat

Given specific speed.

mass_flowfloat

Given mass flow rate.

h0_infloat

Turbine inlet stagnation enthalpy.

d_isfloat

Turbine exit density for an isentropic expansion.

h_isfloat

Turbine exit enthalpy for an isentropic expansion.

Returns:
float

Actual angular speed.

index_variables(variables)[source]

Index the design variables for each cascade for the default initial guess.

The design variables are given without indexing the cascades. For example, the aspect ratio is simply provided by aspect_ratio. This function extend the design_variable dictionary such that for each cascade specific design variable, one item is given for each cascade. for example aspect_ratio_1 for first cascade and etc.

Parameters:
variablesdict

A dictionary where each key maps to a dictionary containing at least a “value” key. The “value” can be a list, numpy array, or float.

Returns:
dict

A dictionary where each list or numpy array in the original dictionary is expanded into individual elements with keys formatted as “key_index”. Float values are kept as is.

init_black_box_constrained(config)[source]
init_gradient_based(config)[source]
init_gradient_free(config)[source]
update_boundary_conditions(design_point)[source]

Update the boundary conditions of the turbine analysis problem with the design point of the design optimization problem.

This method updates the boundary conditions attributes used to evaluate the turbine performance. It also initializes a Fluid object using the ‘fluid_name’ specified in the operation point. The method computes additional properties and reference values like stagnation properties at the inlet, exit static properties, spouting velocity, and reference mass flow rate. These are stored in the object’s internal state for further use in calculations.

Parameters:
design_pointdict

A dictionary containing the boundary conditions defining the operation point. It must include the following keys:

  • fluid_name (str) : The name of the fluid to be used in the Fluid object.

  • T0_in (float): The inlet temperature (in Kelvin).

  • p0_in (float): The inlet pressure (in Pascals).

  • p_out (float): The outlet pressure (in Pascals).

  • omega (float): The rotational speed (in rad/s).

  • alpha_in (float): The inlet flow angle (in degrees).

Returns:
None

This method does not return a value but updates the attributes of the object.

class turboflow.axial_turbine.design_optimization.SolverContainer[source]

Bases: object

turboflow.axial_turbine.design_optimization.build_config(filename, performance_map, solver_options, initial_guess)[source]

Build configuration from CascadesOptimizationProblem object

turboflow.axial_turbine.design_optimization.compute_optimal_turbine(config, out_filename=None, out_dir='output', export_results=True, logger=None)[source]

Calculate the optimal turbine configuration based on the specified optimization problem.

The function checks the configuration file before performing design optimization.

Parameters:
configdict

A dictionary containing necessary configuration options for computing optimal turbine.

initial_guessNone or dict

The initial guess of the design optimization. If None, a defualt initial guess is provided. If given, he initial guess must correspond with the given set of design variables given in the configuration dictionary.

Returns:
solutionobject

The solution object containing the results of the design optimization.