bmgen package#

Subpackages#

Submodules#

bmgen.base_generator module#

class bmgen.base_generator.BaseGenerator#

Bases: ABC

abstract add(line)#
abstract ast()#
abstract generate()#

bmgen.battery module#

class bmgen.battery.Battery(nominalCapacity: float | None = None, minVoltage: float | None = None, maxVoltage: float | None = None, nominalVoltage: float | None = None, eodVoltage: float | None = None, eocVoltage: float | None = None, contChargeCurrent: float | None = None, peakChargeCurrent: float | None = None, contDischargeCurrent: float | None = None, peakDischargeCurrent: float | None = None, minChargeTemperature: float | None = None, maxChargeTemperature: float | None = None, minDischargeTemperature: float | None = None, maxDischargeTemperature: float | None = None, weight: float | None = None, nominalCurrent: float | None = None, energyDensity: float | None = None, internalResistance: float | None = None, oneC: float | None = None)#

Bases: object

This class can be used to reference battery parameters in a cycling program. Parameters can be set to fixed values or translated to variables for the cycler.

contChargeCurrent: float | None = None#

Maximum constant charge current in A.

contDischargeCurrent: float | None = None#

Maximum constant discharge current in A.

energyDensity: float | None = None#

Energy density in Wh/l.

eocVoltage: float | None = None#

End-of-charge voltage for standard charging in V.

eodVoltage: float | None = None#

End-of-discharge voltage for standard discharging in V.

internalResistance: float | None = None#

Internal resistance in Ohm.

maxChargeTemperature: float | None = None#

Maximum charge temperature in °C.

maxDischargeTemperature: float | None = None#

Maximum discharge temperature in °C.

maxVoltage: float | None = None#

Upper voltage limit that must not be exceeded in V.

minChargeTemperature: float | None = None#

Minimum charge temperature in °C.

minDischargeTemperature: float | None = None#

Minimum discharge temperature in °C.

minVoltage: float | None = None#

Lower voltage limit that must not be exceeded in V.

nominalCapacity: float | None = None#

Nominal capcity of the battery in Ah.

nominalCurrent: float | None = None#

Nominal current in A.

nominalVoltage: float | None = None#

Nominal voltage in V.

oneC: float | None = None#

Current that is equal to 1C in A.

peakChargeCurrent: float | None = None#

Peak charge current in A.

peakDischargeCurrent: float | None = None#

Peak discharge current in A.

weight: float | None = None#

Weight of the battery in g.

class bmgen.battery.BatteryParametersNotSupported(nominalCapacity: float | None = None, minVoltage: float | None = None, maxVoltage: float | None = None, nominalVoltage: float | None = None, eodVoltage: float | None = None, eocVoltage: float | None = None, contChargeCurrent: float | None = None, peakChargeCurrent: float | None = None, contDischargeCurrent: float | None = None, peakDischargeCurrent: float | None = None, minChargeTemperature: float | None = None, maxChargeTemperature: float | None = None, minDischargeTemperature: float | None = None, maxDischargeTemperature: float | None = None, weight: float | None = None, nominalCurrent: float | None = None, energyDensity: float | None = None, internalResistance: float | None = None, oneC: float | None = None)#

Bases: Battery

class bmgen.battery.CyclerBattery(nominalCapacity: float | None = None, minVoltage: float | None = None, maxVoltage: float | None = None, nominalVoltage: float | None = None, eodVoltage: float | None = None, eocVoltage: float | None = None, contChargeCurrent: float | None = None, peakChargeCurrent: float | None = None, contDischargeCurrent: float | None = None, peakDischargeCurrent: float | None = None, minChargeTemperature: float | None = None, maxChargeTemperature: float | None = None, minDischargeTemperature: float | None = None, maxDischargeTemperature: float | None = None, weight: float | None = None, nominalCurrent: float | None = None, energyDensity: float | None = None, internalResistance: float | None = None, oneC: float | None = None)#

Bases: Battery

class bmgen.battery.PredefindedBattery(nominalCapacity: float | None = None, minVoltage: float | None = None, maxVoltage: float | None = None, nominalVoltage: float | None = None, eodVoltage: float | None = None, eocVoltage: float | None = None, contChargeCurrent: float | None = None, peakChargeCurrent: float | None = None, contDischargeCurrent: float | None = None, peakDischargeCurrent: float | None = None, minChargeTemperature: float | None = None, maxChargeTemperature: float | None = None, minDischargeTemperature: float | None = None, maxDischargeTemperature: float | None = None, weight: float | None = None, nominalCurrent: float | None = None, energyDensity: float | None = None, internalResistance: float | None = None, oneC: float | None = None)#

Bases: Battery

bmgen.bmgen module#

bmgen.bmgen.generate(file, target, format, intermediate, out, no_timestamps=False, battery=None, config=None, name=None)#
bmgen.bmgen.output(target, text)#

bmgen.channel module#

bmgen.channel.I: float#

Current measurement in A.

bmgen.channel.StepCharge: float#

Charge throughput of the current step in Ah.

bmgen.channel.T: float#

Temperature measurement in °C.

bmgen.channel.Tenv: float#

Environment temperature measurement in °C.

bmgen.channel.V: float#

Voltage measurement in V.

bmgen.channel.channel(name: str) float#

Define a custom channel.

Parameters:

name (str) – Name of the custom channel that is recognized by the targeted cycler.

Returns:

Channel value that can be used in limits in calculations.

Return type:

float

bmgen.converter module#

class bmgen.converter.Converter#

Bases: object

convert(ast)#
convert_node(node)#
fallback: Converter | None = None#
exception bmgen.converter.ConverterError#

Bases: Exception

bmgen.function module#

bmgen.function.charge(current: float, voltage: float | None = None, limits: List[bool] = [], registrations: List = []) StepInfo#

Charge the battery connected to the cycler circuit.

Parameters:
  • current (float) – Current setpoint in Ampere.

  • voltage (float | None) – Voltage setpoint in Volt, defaults to None.

  • limits (List[bool]) – List of limits, see the limit() function, defaults to [].

  • registrations (List) – List of registrations, see the register() function, defaults to [].

Returns:

StepInfo object containing information about the executed step.

Return type:

StepInfo

bmgen.function.discharge(current: float, voltage: float | None = None, limits: List[bool] = [], registrations: List = []) StepInfo#

Discharge the battery connected to the cycler circuit.

Parameters:
  • current (float) – Current setpoint in Ampere.

  • voltage (float | None) – Voltage setpoint in Volt, defaults to None.

  • limits (List[bool]) – List of limits, see the limit() function, defaults to [].

  • registrations (List) – List of registrations, see the register() function, defaults to [].

Returns:

StepInfo object containing information about the executed step.

Return type:

StepInfo

bmgen.function.error(errnum: int)#

Set an error as the action for a limit.

An error will stop the execution of the current program until it is continued by an operator.

Parameters:

errnum (int) – A number specifying what kind of error occured. The meaning of each numbers depends on the selected cycler target.

bmgen.function.hours(value: float) time#

Convenience method to create a time instance with the hours attribute set.

Parameters:

value (float) – The number of hours.

Return type:

time

bmgen.function.limit(condition: bool, action=None)#

Define a limit for the current program step or the entire program.

Limits can be defined for one step if they are passed in the limits parameter. If a limit is defined on its own, it will apply to the entire program. In this case, an action must be specified, e.g. error().

Parameters:
  • condition (bool) – Condition that will trigger the limit once it is reached.

  • action (_type_, optional) – Action to take once the limit condition is met. If this is None, the next step in the program will be executed.

bmgen.function.message(errnum: int)#

Set a message as the action for a limit.

A message is informational and will not stop the execution of the current program.

Parameters:

errnum (int) – A number specifying what kind of error occured. The meaning of each numbers depends on the selected cycler target.

bmgen.function.minutes(value: float) time#

Convenience method to create a time instance with the minutes attribute set.

Parameters:

value (float) – The number of minutes.

Return type:

time

bmgen.function.pause(limits: List[bool] = [], hours: float | None = None, minutes: float | None = None, seconds: float | None = None, registrations: List = []) StepInfo#

Pause the program until a limit is reached.

Limits can be set using the limit argument. The arguments hours, minutes, and seconds are provided as a shorthand to set a time-based limit. They act the same way as the the time() function.

Parameters:
  • limits (List[bool], optional) – List of limits, see the limit() function, defaults to [].

  • hours (float | None, optional) – Hours of the time-based limit, defaults to None.

  • minutes (float | None, optional) – Minutes of the time-based limit, defaults to None.

  • seconds (float | None, optional) – Seconds of the time-based limit, defaults to None.

  • registrations (List, optional) – List of registrations, see the register() function, defaults to [].

Returns:

StepInfo object containing information about the executed step.

Return type:

StepInfo

bmgen.function.register(time: time | None = None, voltage: float | None = None, current: float | None = None, format: List | None = None)#
bmgen.function.seconds(value: float) time#

Convenience method to create a time instance with the seconds attribute set.

Parameters:

value (float) – The number of seconds.

Return type:

time

class bmgen.function.time(hours: float | None = None, minutes: float | None = None, seconds: float | None = None)#

Bases: object

Object expressing a timespan that can be used for defining limits.

The timespan can be set using different units. If multiple values are set, the will be converted to one unit and added together, e.g. minutes=1 and seconds=30 will result in seconds=90.

hours: float | None = None#
minutes: float | None = None#
seconds: float | None = None#

bmgen.stepinfo module#

class bmgen.stepinfo.StepInfo(charge: float)#

Bases: object

charge: float#

bmgen.transformer module#

class bmgen.transformer.Transformer(target)#

Bases: NodeTransformer

visit_Assign(node)#
visit_Expr(node)#
visit_Import(node)#
visit_ImportFrom(node)#
visit_Module(node)#

Module contents#

bmgen.get_version()#