예제 #1
0
def getRand(b_):
    """Returns uniformly distributed vectors on the surface of a sphere with radius b_."""
    x1 = x2 = 1.0
    while (x1**2 + x2**2 >= 1.0):
        x1 = 2.0 * random.random() - 1.0
        x2 = 2.0 * random.random() - 1.0
    x = 2.0 * x1 * (1 - x1**2 - x2**2)**0.5
    y = 2.0 * x2 * (1 - x1**2 - x2**2)**0.5
    z = 1.0 - 2.0 * (x1**2 + x2**2)
    return (x * b_, y * b_, z * b_)


for file in blockfiles:

    fmanager = pypolymer.read_blockfile(file)
    timestep = fmanager[0]
    total_particles = fmanager[1]
    M_rings = fmanager[2]
    M_linear = fmanager[3]
    monomers = fmanager[4]
    monomers_half = fmanager[5]
    x = fmanager[6]
    y = fmanager[7]
    z = fmanager[8]

    if (file == blockfiles[0]):
        total_particles1st = total_particles
        sys.stdout.write('System parameters:\n')
        sys.stdout.write('  M_rings = ' + str(M_rings) + '\n')
        sys.stdout.write('  M_linear = ' + str(M_linear) + '\n')
예제 #2
0
def getRand(b_):
    """Returns uniformly distributed vectors on the surface of a sphere with radius b_."""
    x1 = x2 = 1.0
    while x1 ** 2 + x2 ** 2 >= 1.0:
        x1 = 2.0 * random.random() - 1.0
        x2 = 2.0 * random.random() - 1.0
    x = 2.0 * x1 * (1 - x1 ** 2 - x2 ** 2) ** 0.5
    y = 2.0 * x2 * (1 - x1 ** 2 - x2 ** 2) ** 0.5
    z = 1.0 - 2.0 * (x1 ** 2 + x2 ** 2)
    return (x * b_, y * b_, z * b_)


for file in blockfiles:

    fmanager = pypolymer.read_blockfile(file)
    timestep = fmanager[0]
    total_particles = fmanager[1]
    M_rings = fmanager[2]
    M_linear = fmanager[3]
    monomers = fmanager[4]
    monomers_half = fmanager[5]
    x = fmanager[6]
    y = fmanager[7]
    z = fmanager[8]

    if file == blockfiles[0]:
        total_particles1st = total_particles
        sys.stdout.write("System parameters:\n")
        sys.stdout.write("  M_rings = " + str(M_rings) + "\n")
        sys.stdout.write("  M_linear = " + str(M_linear) + "\n")