def test_state_average_mix(self):
    solver1 = fci.FCI(mol)
    solver1.spin = 0
    solver1.nroots = 2
    solver2 = fci.FCI(mol, singlet=False)
    solver2.spin = 2
    mc = mcscf.CASSCF(mfr, 4, 4)
    mc = mcscf.addons.state_average_mix_(mc, [solver1, solver2], (0.25, 0.25, 0.5))
    mc.kernel()
    e = mc.e_states
    self.assertAlmostEqual(mc.e_tot, (- 108.80340952016508), 7)
    self.assertAlmostEqual(mc.e_average, (- 108.80340952016508), 7)
    self.assertAlmostEqual(numpy.dot(e, [0.25, 0.25, 0.5]), (- 108.80340952016508), 7)
    dm1 = mc.analyze()
    self.assertAlmostEqual(lib.fp(dm1[0]), 0.5217266954935746, 4)
    self.assertAlmostEqual(lib.fp(dm1[1]), 0.5336677601786902, 4)
    self.assertAlmostEqual(lib.fp((dm1[0] + dm1[1])), 1.0553944556722636, 4)
    mc.cas_natorb()
def test_state_average_mix(self):
    solver1 = fci.FCI(mol)
    solver1.spin = 0
    solver1.nroots = 2
    solver2 = fci.FCI(mol, singlet=False)
    solver2.spin = 2
    mc = mcscf.CASSCF(mfr, 4, 4)
    mc = mcscf.addons.state_average_mix_(mc, [solver1, solver2], (0.25, 0.25, 0.5))
    mc.kernel()
    e = mc.e_states
    self.assertAlmostEqual(mc.e_tot, (- 108.80340952016508), 7)
    self.assertAlmostEqual(mc.e_average, (- 108.80340952016508), 7)
    self.assertAlmostEqual(numpy.dot(e, [0.25, 0.25, 0.5]), (- 108.80340952016508), 7)
    dm1 = mc.analyze()
    self.assertAlmostEqual(lib.fp(dm1[0]), 0.5217266954935746, 4)
    self.assertAlmostEqual(lib.fp(dm1[1]), 0.5336677601786902, 4)
    self.assertAlmostEqual(lib.fp((dm1[0] + dm1[1])), 1.0553944556722636, 4)
    mc.cas_natorb()