code: def define_passive_branch_flows_with_kirchhoff(network,snapshots,skip_vars=False):
      
  
      for sub_network in network.sub_networks.obj:
          find_tree(sub_network)
          find_cycles(sub_network)
  
          #following is necessary to calculate angles post-facto
          find_bus_controls(sub_network)
          if len(sub_network.branches_i()) > 0:
              calculate_B_H(sub_network)
  
      passive_branches = network.passive_branches()
  
      if not skip_vars:
          network.model.passive_branch_p = Var(list(passive_branches.index), snapshots)
  
      cycle_index = []
      cycle_constraints = {}
  
      for subnetwork in network.sub_networks.obj:
  
          branches = subnetwork.branches()
          attribute = "r_pu_eff" if network.sub_networks.at[subnetwork.name,"carrier"] == "DC" else "x_pu_eff"
  
          sub_network_cycle_index, sub_network_cycle_constraints = define_sub_network_cycle_constraints( subnetwork,
                                                                                                         snapshots,
                                                                                                         network.model.passive_branch_p, attribute)
  
          cycle_index.extend( sub_network_cycle_index)
          cycle_constraints.update( sub_network_cycle_constraints)
  
      l_constraint(network.model, "cycle_constraints", cycle_constraints,
                   cycle_index, snapshots)
docs: define passive branch flows with the kirchoff method