For such a simple circuit, probably the easier way is to dump it as QASM and read it back.
def split_circuit_by_barrier(circuit):
qasm = circuit.qasm()
prelude = []
circuits = [[]]
for line in qasm.splitlines():
if any([line.startswith(t) for t in ['OPENQASM', 'include', 'qreg', 'creg']]):
prelude.append(line)
elif line.startswith('barrier'):
circuits.append([])
else:
circuits[-1].append(line)
circuits_with_prelude = [prelude+circuit for circuit in circuits]
for circuit_with_prelude in circuits_with_prelude:
yield QuantumCircuit.from_qasm_str('\n'.join(circuit_with_prelude))
Taking your example:
for subcircuit in (split_circuit_by_barrier(circuit)):
print(subcircuit)
┌───┐ ┌───┐
q_0: ─────────────────■───┤ H ├─┤ S ├─────
┌───┐┌───┐┌───┐┌─┴─┐┌┴───┴┐├───┤┌───┐
q_1: ┤ H ├┤ H ├┤ S ├┤ X ├┤ SDG ├┤ H ├┤ X ├
└───┘└───┘└───┘└───┘└─────┘└───┘└───┘
meas: 2/═════════════════════════════════════
┌─────┐┌───┐
q_0: ┤ SDG ├┤ H ├───────■───────────────────
└┬───┬┘├───┤┌───┐┌─┴─┐┌─────┐┌───┐┌───┐
q_1: ─┤ X ├─┤ H ├┤ S ├┤ X ├┤ SDG ├┤ H ├┤ H ├
└───┘ └───┘└───┘└───┘└─────┘└───┘└───┘
meas: 2/═══════════════════════════════════════
┌─┐
q_0: ┤M├───
└╥┘┌─┐
q_1: ─╫─┤M├
║ └╥┘
meas: 2/═╩══╩═
0 1