Cairn API documentation

CairnAPI

class cairn.CairnAPI

Bases: pybind11_object

class ESettingsLimited

Bases: pybind11_object

Members:

all

mandatory

optional

used

all = <ESettingsLimited.all: 0>
mandatory = <ESettingsLimited.mandatory: 1>
property name
optional = <ESettingsLimited.optional: 2>
used = <ESettingsLimited.used: 3>
property value
close_study(self: cairn.bin.cairn.CairnAPI) None

close the current study

component_type(self: cairn.bin.cairn.CairnAPI, model: str) str

returns the type of a given model

create_study(self: cairn.bin.cairn.CairnAPI, arg0: str) CairnAPI::OptimProblemAPI

creates study with a given name

read_study(self: cairn.bin.cairn.CairnAPI, fileName: str) CairnAPI::OptimProblemAPI

reads a study from file

all = <ESettingsLimited.all: 0>
property all_models
property carrier_types
property component_types
mandatory = <ESettingsLimited.mandatory: 1>
optional = <ESettingsLimited.optional: 2>
property solvers
used = <ESettingsLimited.used: 3>

OptimProblem

class cairn.OptimProblem

Bases: pybind11_object

OptimProblem class.

add_label(self: cairn.bin.cairn.OptimProblem, arg0: str) None

add a label to the problem

adds a link between two given ports

add_timeseries(self: cairn.bin.cairn.OptimProblem, arg0: str) None

adds a given timeseries file

create_bus(self: cairn.bin.cairn.OptimProblem, arg0: str, arg1: str, arg2: CairnAPI::EnergyVectorAPI) CairnAPI::BusAPI

creates and returns a new bus with a given name, model and energy carrier, e.g., create_bus(‘H2_Bus’, ‘NodeLaw’, vH2)

create_component(self: cairn.bin.cairn.OptimProblem, arg0: str, arg1: str) CairnAPI::MilpComponentAPI

creates and returns a new component with a given name and model, e.g., create_component(‘Elec_Grid’, ‘GridFree’)

create_energy_carrier(self: cairn.bin.cairn.OptimProblem, arg0: str, arg1: str) CairnAPI::EnergyVectorAPI

creates and returns a new energy carrier with a given name and type, e.g., create_energy_carrier(‘H2’, ‘FluidH2’)

export_parameters(self: cairn.bin.cairn.OptimProblem, filename: str = '', optionsMap: collections.abc.Mapping[str, bool] = {}) None

exports the study parameters to a csv file

export_plan(self: cairn.bin.cairn.OptimProblem, filename: str = '', solNb: SupportsInt = 0) None

exports PLAN results to a csv file

get_all_indicators_values(self: cairn.bin.cairn.OptimProblem, range: str = 'PLAN') dict[str, float | int | str | list[str] | list[float] | list[int]]

returns the indicators of all components for a given range, by default PLAN value

get_bus(self: cairn.bin.cairn.OptimProblem, arg0: str) CairnAPI::BusAPI

returns a given bus

get_component(self: cairn.bin.cairn.OptimProblem, arg0: str) CairnAPI::MilpComponentAPI

returns a given component

get_components(self: cairn.bin.cairn.OptimProblem, category: str = '') list[str]

returns all the components of the optim problem specifying the category if needed

get_energy_carrier(self: cairn.bin.cairn.OptimProblem, arg0: str) CairnAPI::EnergyVectorAPI

returns a given energy carrier

get_indicator_value(self: cairn.bin.cairn.OptimProblem, name: str, range: str = 'PLAN') float

returns the result of a given TecEco indicator for a given range, by default PLAN value

get_indicators_values(self: cairn.bin.cairn.OptimProblem, range: str = 'PLAN') dict[str, float | int | str | list[str] | list[float] | list[int]]

returns the TecEco indicators for a given range, by default PLAN value

get_object(self: cairn.bin.cairn.OptimProblem, arg0: str) CairnAPI::ObjectAPI

returns a given object

get_simulation_control(self: cairn.bin.cairn.OptimProblem) CairnAPI::SimulationControlAPI

return SimulationControl

get_solver(self: cairn.bin.cairn.OptimProblem) CairnAPI::SolverAPI

return Solver

get_tech_eco_analysis(self: cairn.bin.cairn.OptimProblem) CairnAPI::TecEcoAnalysisAPI

return TecEcoAnalysis

remove_bus(self: cairn.bin.cairn.OptimProblem, arg0: CairnAPI::BusAPI) None

removes a given bus

remove_component(self: cairn.bin.cairn.OptimProblem, arg0: CairnAPI::MilpComponentAPI) None

removes a geiven component from the optim problem

remove_energy_carrier(self: cairn.bin.cairn.OptimProblem, arg0: CairnAPI::EnergyVectorAPI) None

removes a given energy carrier from the optim problem

remove_label(self: cairn.bin.cairn.OptimProblem, arg0: str) None

remove a label from the problem

removes a given link

run(self: cairn.bin.cairn.OptimProblem, resultsPath: str = '') CairnAPI::SolutionAPI

runs the optim problem

save_study(self: cairn.bin.cairn.OptimProblem, filename: str, mode: str = '') None

saves a study with a given name (it can also take a mode to position the components e.g. gradient)

property buses
property components
property energy_carriers

returns all the energy carriers of the optim problem

property indicators
property indicators_shortnames
property indicators_units
property labels

get/set the labels of the problem

property objects
property optimized_components

CairnObject

class cairn.CairnObject

Bases: pybind11_object

Object class.

get_setting_value(self: cairn.bin.cairn.CairnObject, arg0: str) float | int | str | list[str] | list[float] | list[int]

returns the value of a given parameter

get_settings(self: cairn.bin.cairn.CairnObject, setLimited: cairn.bin.cairn.CairnAPI.ESettingsLimited = <ESettingsLimited.all: 0>) list[str]

returns a list of all (by default), used, optional or mandatory parameter names

rename(self: cairn.bin.cairn.CairnObject, arg0: str) None

rename EnergyVector component

set_setting_value(self: cairn.bin.cairn.CairnObject, name: str, value: SupportsFloat | SupportsInt | str | collections.abc.Sequence[str] | collections.abc.Sequence[SupportsFloat] | collections.abc.Sequence[SupportsInt], verify: bool = True) None

sets the value of a given parameter

property name
property objectType
property setting_values

get/set all parameters as a dictionary

property settings

returns a list of all parameter names

property show_config

returns ShowConfig of a given parameter. The parameter is displayed in the GUI when this ShowConfig is selected in the DataFilter

property show_configs

returns a list of all ShowConfigs which is used in the GUI DataFilter

EnergyVector

class cairn.EnergyVector

Bases: CairnObject

EnergyCarrier class. The constructor takes several arguments: arg1: OptimProblemAPI aProblem, the study where the EnergyVector will be added arg2: string aName to give the name of the energy vector arg3: string aType to give the type of the energy vector (list available thanks to property carrier_types of CairnAPI)

property type

Bus

class cairn.Bus

Bases: CairnObject

Bus class. The constructor takes several arguments: arg1: OptimProblemAPI aProblem, the study where the Bus will be added arg2: string aName to give the name of the bus arg3: string aModelName to give the model. Available Bus models are NodeLaw, NodeEquality and ManualObjective arg4: string aEnergyVector to give the energy vector of the bus

get_indicator_value(self: cairn.bin.cairn.Bus, name: str, range: str = 'PLAN') float

returns the result of a given indicator for a given range, by default PLAN value

get_indicators_values(self: cairn.bin.cairn.Bus, range: str = 'PLAN') dict[str, float | int | str | list[str] | list[float] | list[int]]

returns the indicators for a given range, by default PLAN value

get_label_value(self: cairn.bin.cairn.Bus, arg0: str) str

return the value of a given label

get_var_value(self: cairn.bin.cairn.Bus, arg0: str) float | int | str | list[str] | list[float] | list[int]

returns the result of a given IO for the optimal solution

get_var_values(self: cairn.bin.cairn.Bus) dict[str, float | int | str | list[str] | list[float] | list[int]]

returns the result of all IOs for the optimal solution

set_label_value(self: cairn.bin.cairn.Bus, arg0: str, arg1: str) None

set the value of a given label

property indicators
property indicators_shortnames
property indicators_units
property label_values

get/set all label values as a dictionary

property model_class
property type
property variables

Port

class cairn.Port

Bases: CairnObject

Port class. The constructor takes several arguments: arg1: MilpComponentAPI aComponent which will own the port arg2: string aName to give the name of the port arg3: EnergyVectorAPI aEnergyVector to give the energy vector of the port arg3 (optional): string aDirection (Input, Output or DataExchange) to set the direction of the port arg3 (optional): string aVariable to set the variable of the port

set_carrier(self: cairn.bin.cairn.Port, arg0: cairn.bin.cairn.EnergyVector) None

sets the energy carrier of the port (takes componenet not name)

property carrier_name

return the name of energy carrier

Component

class cairn.Component

Bases: CairnObject

Component class. The constructor takes several arguments: arg1: OptimProblemAPI aProblem, the study where the component will be added arg2: string aName to give the name of the component arg3: string aModelName to give the model (list available thanks to property all_models of CairnAPI). Note that, to create componenets NodeLaw, NodeEquality and ManualObjective use BusAPI

add_port(self: cairn.bin.cairn.Component, name: str, carrier: cairn.bin.cairn.EnergyVector, direction: str = 'DATAEXCHANGE', variable: str = '', reinitializeCompo: bool = True) cairn.bin.cairn.Port

creates a new port for the component

get_indicator_value(self: cairn.bin.cairn.Component, name: str, range: str = 'PLAN') float

returns the result of a given indicator for a given range, by default PLAN value

get_indicators_values(self: cairn.bin.cairn.Component, range: str = 'PLAN') dict[str, float | int | str | list[str] | list[float] | list[int]]

returns the indicators for a given range, by default PLAN value

get_label_value(self: cairn.bin.cairn.Component, arg0: str) str

return the value of a given label

get_port(self: cairn.bin.cairn.Component, arg0: str) cairn.bin.cairn.Port

returns a given port from the component

get_timeseries_vector(self: cairn.bin.cairn.Component, arg0: str) float | int | str | list[str] | list[float] | list[int]

returns the vector value of a given timeseries parameter

get_var_value(self: cairn.bin.cairn.Component, arg0: str) float | int | str | list[str] | list[float] | list[int]

returns the result of a given IO for the optimal solution

get_var_values(self: cairn.bin.cairn.Component) dict[str, float | int | str | list[str] | list[float] | list[int]]

returns the result of all IOs for the optimal solution

remove_port(self: cairn.bin.cairn.Component, arg0: cairn.bin.cairn.Port, arg1: bool) bool

removes a given port from the component

set_label_value(self: cairn.bin.cairn.Component, arg0: str, arg1: str) None

set the value of a given label

set_timeseries_vector(self: cairn.bin.cairn.Component, arg0: str, arg1: collections.abc.Sequence[SupportsFloat]) None

sets the vector value of a given timeseries parameter

property default_ports

returns the list of default port names

property dim_param

return the parameter used for dimensionning

property direction

return the direction based on the default port. Valid only for components of types Grid and SourceLoad.

property indicators
property indicators_shortnames
property indicators_units
property is_optimized
property label_values

get/set all label values as a dictionary

property model_class
property optimal_size_expression

returns the name of optimal size (MaxSize) variable. Note, it works only after configuring the carriers of default ports.

property ports

returns the list of all port names

property type
property variables

Solution

class cairn.Solution

Bases: pybind11_object

Solution class.

get_ts_results(self: cairn.bin.cairn.Solution, arg0: SupportsInt) dict[str, list[float | int | str | list[str] | list[float] | list[int]]]

returns the output ts results

property nb_solutions

returns the number of solutions found

property status

returns the status of the run

cairn toolbox

cairn.run_sensitivity(problem, df_sens, max_time=-1, indicators=Empty DataFrame Columns: [] Index: [])

runs sensitivity study of a given problem with a given input dataframe (2 header rows: 1st row: name of the component, 2nd row: name of the parameter and one sensitivity study per row) for an optional maximal duration of each run. arg1: cairn problem arg2: dataframe containing sensitivity studies to be conducted arg3: maximal duration of each sensitivity study (optional) arg4: pandas dataframe of two colums Model and Indicator of KPI to save during sensitivity (file PLAN) :meta public:

cairn.set_param(problem, header_col, value)
cairn.copy_component(problem, component, new_name, connexions=True)

Make a copy of a component, with its parameters and connexions (optional).

Parameters:
  • problem (cairn.OptimProblem) – The problem that will be modified

  • component (str) – The name of component to duplicate

  • new_name (str) – The name of the duplicated component

  • connexions (bool) – If true, the ports and links are also duplicated.

Returns:

compo2 – The new component.

Return type:

cairn.Component