def test_breaksym(): from pylada.dftcrystal import Crystal, Functional, Shell, DisplaceAtoms, read functional = Functional() functional.basis['Si'] = [ Shell('s', a0=[16120.0, 0.001959], a1=[2426.0, 0.01493], a2=[553.9, 0.07285], a3=[156.3, 0.2461], a4=[50.07, 0.4859], a5=[17.02, 0.325]), Shell('sp', a0=[292.7, -0.002781, 0.004438], a1=[69.87, -0.03571, 0.03267], a2=[22.34, -0.115, 0.1347], a3=[8.15, 0.09356, 0.3287], a4=[3.135, 0.603, 0.4496]), Shell('sp', 4.0, a0=[1.22, 1.0, 1.0]), Shell('sp', 0.0, a0=[0.55, 1.0, 1.0]), Shell('sp', 0.0, a0=[0.27, 1.0, 1.0]) ] functional.dft.pbe0 = True functional.fmixing = 30 functional.shrink = 8, 16 functional.levshift = 5, True functional.maxcycle = 600 functional.optgeom.keepsymm = True functional.optgeom.enabled = True crystal = Crystal(227, 5.43).add_atom(0.125, 0.125, 0.125, 'Si') crystal.append('breaksym') crystal.append(DisplaceAtoms().add_atom(0.01, 0, 0, 1)) string = functional.print_input(structure=crystal) assert string.splitlines()[10] == 'KEEPSYMM' cry, func = read(string) assert cry.is_breaksym assert func.optgeom.enabled assert func.optgeom.keepsymm functional.optgeom.keepsymm = False string = functional.print_input(structure=crystal) assert string.splitlines()[10] == 'OPTGEOM' cry, func = read(string) assert cry.is_breaksym assert func.optgeom.enabled assert func.optgeom.breaksym crystal[0] = 'keepsymm' string = functional.print_input(structure=crystal) assert string.splitlines()[11] == 'BREAKSYM' cry, func = read(string) assert not cry.is_breaksym assert func.optgeom.enabled assert func.optgeom.breaksym functional.optgeom.keepsymm = True string = functional.print_input(structure=crystal) assert string.splitlines()[11] == 'OPTGEOM' cry, func = read(string) assert not cry.is_breaksym assert func.optgeom.enabled assert func.optgeom.keepsymm string = crystal.print_input() crystal.append('keepsymm') crystal.append('keepsymm') assert crystal.print_input() == string crystal.append('breaksym') assert crystal.print_input() != string assert len(crystal.print_input().splitlines()) == len(string.splitlines()) + 1