コード例 #1
0
    
    # Which axes should be integrated out?
    assert len(axes_str) == 2
    ax2index = {"x": 0, "y": 1, "z": 2}
    axes_integrate = [ax2index[s] for s in axes_str]
    # Which axis remains?
    axis_remains = None
    for i in range(0,3):
        if not (i in axes_integrate):
            axis_remains = i
            break
    print "axes %s are integrated out" % str(axes_integrate)
    print "remaining axis: %s" % axis_remains

    # load the cube file
    atomlist, origin, axes, data = Cube.readCube(cube_file)
    axes = [np.array(ax) for ax in axes]

    x0 = np.array(origin)
    nx,ny,nz = data.shape
    ns = [nx,ny,nz]

    # remaining coordinate is called u
    du = la.norm(axes[axis_remains])
    print "du = %s" % du
    nu = ns[axis_remains]
    u = np.linspace(origin[axis_remains], nu*du, nu)
    # shift axis so that the center is located at u=0
    u = u-u[len(u)/2]
    # rho(u), 1D curve after integrating
    rho_u = np.zeros(ns[axis_remains])
コード例 #2
0
ファイル: vector_potential.py プロジェクト: humeniuka/DFTBaby
    (opts, args) = parser.parse_args()
    if len(args) < 6:
        print usage
        exit(-1)

    # input cube files
    Mx_cube_file = args[0]
    My_cube_file = args[1]
    Mz_cube_file = args[2]
    # output cube files
    Ax_cube_file = args[3]
    Ay_cube_file = args[4]
    Az_cube_file = args[5]


    # load cube files with magnetic dipole density
    print "load magnetic dipole density from cube files..."
    atomlist, origin, axes, Mx = Cube.readCube(Mx_cube_file)
    atomlist, origin, axes, My = Cube.readCube(My_cube_file)
    atomlist, origin, axes, Mz = Cube.readCube(Mz_cube_file)
    print "compute vector potential..."
    Ax,Ay,Az = vector_potential_Poisson(atomlist, origin, axes, Mx, My, Mz,
                                        poisson_solver=opts.solver,
                                        conv_eps=opts.conv_eps, maxiter=opts.maxiter)
    # save vector potential
    Cube.writeCube(Ax_cube_file, atomlist, origin, axes, Ax)
    Cube.writeCube(Ay_cube_file, atomlist, origin, axes, Ay)
    Cube.writeCube(Az_cube_file, atomlist, origin, axes, Az)
    print "x-,y- and z-components of vector potential saved to '%s', '%s' and '%s'" % (Ax_cube_file, Ay_cube_file, Az_cube_file)

コード例 #3
0
    # input cube files
    # ... for magnetic dipole density
    Mx_cube_file = args[0]
    My_cube_file = args[1]
    Mz_cube_file = args[2]
    # ... vector potential
    Ax_cube_file = args[3]
    Ay_cube_file = args[4]
    Az_cube_file = args[5]
    # output file
    dat_file = args[6]

    # load cube files components of magnetic dipole density
    print "load magnetic dipole densities from cube files..."
    atomlist, origin, axes, Mx = Cube.readCube(Mx_cube_file)
    atomlist, origin, axes, My = Cube.readCube(My_cube_file)
    atomlist, origin, axes, Mz = Cube.readCube(Mz_cube_file)

    dx = la.norm(axes[0])
    dy = la.norm(axes[1])
    dz = la.norm(axes[2])
    # volume element, assuming the axes are orthogonal
    dV = dx * dy * dz
    # find total magnetic dipole moment
    mtot = np.array([np.sum(Mx * dV), np.sum(My * dV), np.sum(Mz * dV)])

    # load cube files for components of vector potential
    print "load magnetic vector potential from cube files..."
    atomlist, origin, axes, Ax_data = Cube.readCube(Ax_cube_file)
    atomlist, origin, axes, Ay_data = Cube.readCube(Ay_cube_file)
コード例 #4
0
        dest="nuclear_potential",
        type=int,
        help=
        "Should the nuclear potential be added to the electrostatic potential (0: no, 1: yes) [default: %default]",
        default=1)

    (opts, args) = parser.parse_args()
    if len(args) < 2:
        print usage
        exit(-1)

    rho_cube_file = args[0]
    pot_cube_file = args[1]

    # load cube file with electronic density
    print "load density from cube file..."
    atomlist, origin, axes, rho = Cube.readCube(rho_cube_file)
    print "compute electrostatic potential..."
    pot = electrostatic_potential_Poisson(
        atomlist,
        origin,
        axes,
        rho,
        poisson_solver=opts.solver,
        conv_eps=opts.conv_eps,
        maxiter=opts.maxiter,
        nuclear_potential=opts.nuclear_potential)
    # save potential
    Cube.writeCube(pot_cube_file, atomlist, origin, axes, pot)
    print "electrostatic potential saved to '%s'" % pot_cube_file