Esempio n. 1
0
    if debug:
        print("=== %s ===" % sol.__class__)
    for name, target_M, nnd, a in systems:
        syms = a.get_chemical_symbols()
        
        #a.set_charges([ (Q if sym == syms[0] else -Q) for sym in syms ])
        # to work with older versions
        a.set_initial_charges([ (-Q,Q)[sym==syms[0]] for sym in syms ])

        a.translate([0.25*a0,0.25*a0,0.25*a0])
        if debug:
            write("%s.cfg" % name, a)

        ha = HotbitAtoms(a, container='Bravais')

        sol.update(ha, ha.get_initial_charges())

        phi  = sol.get_potential()
        e    = np.sum(a.get_initial_charges()*phi)/2
        M    = -2*e*a0*nnd/(len(a))
        err  = abs(M-target_M)

        if debug:
            print("%20s   %8.6f  %8.6f  (%8.6e)" % ( name, M, target_M, err ))

        assert err < 1e-3

            

if debug:
    for sol in solvers:
Esempio n. 2
0
    if debug:
        print "=== %s ===" % sol.__class__
    for name, target_M, nnd, a in systems:
        syms = a.get_chemical_symbols()
        
        #a.set_charges([ (Q if sym == syms[0] else -Q) for sym in syms ])
        # to work with older versions
        a.set_initial_charges([ (-Q,Q)[sym==syms[0]] for sym in syms ])

        a.translate([0.25*a0,0.25*a0,0.25*a0])
        if debug:
            write("%s.cfg" % name, a)

        ha = HotbitAtoms(a, container='Bravais')

        sol.update(ha, ha.get_initial_charges())

        phi  = sol.get_potential()
        e    = np.sum(a.get_initial_charges()*phi)/2
        M    = -2*e*a0*nnd/(len(a))
        err  = abs(M-target_M)

        if debug:
            print "%20s   %8.6f  %8.6f  (%8.6e)" % ( name, M, target_M, err )

        assert err < 1e-3

            

if debug:
    for sol in solvers: