paddle_quantum.data_analysis.power_flow

Power Flow model

class paddle_quantum.data_analysis.power_flow.Bus(data, name)

Bases: object

The class of buses in power flow model.

Parameters:
  • data (List[float]) – A list of data of the bus.

  • name (str) – The name of the bus.

property V: complex

Calculate the voltage of the bus.

Returns:

Return the voltage of the bus.

class paddle_quantum.data_analysis.power_flow.Branch(branchIndex, fromBus, toBus, data)

Bases: object

The class of branch between different buses in power system.

Parameters:
  • branchIndex (int) – The index of the branch.

  • fromBus (int) – The index of tap bus of the branch.

  • toBus (int) – The index of Z bus of the branch.

  • data (List[float]) – A list of data of the branch.

class paddle_quantum.data_analysis.power_flow.Grid(buses, branches, Mva_base)

Bases: object

The class of power grid.

Parameters:
  • buses (List[Bus]) – The list of all buses in the grid.

  • branches (List[Branch]) – The list of all braches in the grid.

  • Mva_base (float) – Mva base of power system.

property bus_num: int

Get the number of buses in the power system.

Returns:

Return the number of buses.

get_bus_by_number(number)

Get the bus with given number.

Parameters:

number (int) – The bus number.

Returns:

Return the bus with given number.

Raises:

NameError – No bus with given number.

Return type:

Bus

get_branch_by_number(number)

Get the branch with given number.

Parameters:

number (int) – The branch number.

Returns:

Return the branch with given number.

Raises:

NameError – No branch with given number.

Return type:

Branch

get_branches_by_bus(busNumber)

Get branches of the bus with given bus number.

Parameters:

number – The bus number.

Returns:

Return the branches of the bus with given bus number.

Return type:

List[Branch]

property pq_buses
property pv_buses
powerflow(threshold, minIter, maxIter, depth, iterations, LR, gamma=0)

Power flow solving process.

Parameters:
  • threshold – Threshold for loss value to end optmization for power flow.

  • minIter (int) – Minimum number of iterations of power flow optimization.

  • maxIter (int) – Maximum number of iteration of power flow optimization.

  • depth (int) – The depth of quantum ansatz circuit.

  • iterations (int) – Number of optimization cycles of quantum circuit.

  • LR (float) – The learning rate of the optimizer.

  • gamma (float | None) – Threshold for loss value to end optimization for quantum circuit early, default is 0.

printResults()

Print the result of power flow.

saveResults()

Save the result of power flow.

paddle_quantum.data_analysis.power_flow.compute(A, b, depth, iterations, LR, gamma=0)

Solve the branchar equation Ax=b.

Parameters:
  • A (ndarray) – Input matrix.

  • b (ndarray) – Input vector.

  • depth (int) – Depth of ansatz circuit.

  • iterations (int) – Number of iterations for optimization.

  • LR (float) – Learning rate of optimizer.

  • gamma (float | None) – Extra option to end optimization early if loss is below this value. Default to ‘0’.

Returns:

Return the vector x that solves Ax=b.

Raises:
  • ValueError – A is not a square matrix.

  • ValueError – dimension of A and b don’t match.

  • ValueError – A is a singular matrix hence there’s no unique solution.

Return type:

ndarray

paddle_quantum.data_analysis.power_flow.data_to_Grid(file_name)

Transfer the data file to power grid.

Parameters:

file_name – The file name of power system data.

Returns:

Return the power grid.

Return type:

Grid