def run(
    normal_force = 0,
    sled_conditions = (9, 25),  # num particles in sled, floor
    pulling_force_v = 0.1,
    neighbor_facilitator = None
    ):
    global containers, lstats
    lj_method = 'dm' if neighbor_facilitator is None else 'nl'  # LJ method used either distance matrix or neighbor list
    info_for_naming = '{}-{} W={:.0f} Fpv={:.2f} Fpk={:.1f} dt={:.2f} k={:.1f} Fdm={:.1f}'.format(sled_conditions, lj_method, normal_force, pulling_force_v, pulling_force_k, dt, sled_k, damp_force_multiplier)

    print 'running with', info_for_naming

    init_container, last_particle_position = create(*sled_conditions)
    containers = [init_container]
    integrator = VerletIntegrator()
    sled_forcer = moldyn.SledForcer(2*a, u=last_particle_position, k=sled_k)
    sled_forcer.pulling_force_v = pulling_force_v
    sled_forcer.pulling_force_k = pulling_force_k
    sled_forcer.allow_negative_pull_force = allow_negative_pull_force
    sled_forcer.damp_force_multiplier = damp_force_multiplier
    sled_forcer.normal_force = normal_force
    integrator.sled_forcer = sled_forcer
    integrator.neighbor_facilitator = neighbor_facilitator

    run_func = None# RunFunc(last_particle_position)
    graphical.animate_with_live_integration(containers, integrator, dt, xlim, ylim, figsize, particle_radius, frame_show_modulus, num_frames_to_bootstrap, info_for_naming, save_animation, show_animation, run_func,
    anim_save_kwargs = anim_save_kwargs)

    stats = SimStats(info_for_naming, containers,
        sled_size = sled_conditions[0],
        W = normal_force,
        Fpv = pulling_force_v,
        Fpk = pulling_force_k,
        dt = dt,
        sled_k = sled_k,
        Fdm = damp_force_multiplier)
    lstats.append(stats)
    graphical.plot_pulling_force(stats.times, stats.pulling_forces, normal_force=stats.W, info_for_naming=info_for_naming, show=False)
num_forward_frames = 100
frame_show_modulus = 10  # only show every nth frame
dt = 1e-2
sim_name = ['symmetry', 'line', 'problem_1', 'problem_3'][0]
extra_params = {
    'symmetry_number': 'eight',
    'Lx': 10,  # only for line
    'random_velocity': 0, 'random_particle_ix': None,
    'lattice': ['triangle', 'square'][1]}


init_container, special_particles = get_container_for(sim_name, **extra_params)
print 'special_particles:', special_particles

containers = [init_container]
integrator = VerletIntegrator()
for i in xrange(num_forward_frames):
    next_container = integrator.step(containers[-1], dt)
    containers.append(next_container)
end_container = containers[-1]

# Now run... backwards!
if also_run_backwards:
    for i in xrange(num_forward_frames):
        next_container = integrator.step(containers[-1], -dt)
        containers.append(next_container)

# Animate orbit
# Code courtesy of George Lesica
fig = pl.figure(figsize=(4, 4))
xlim, ylim = init_container.bounds
Ejemplo n.º 3
0
def run(neighbor_facilitator=None):
    global containers, lstats, p
    lj_method = "dm" if neighbor_facilitator is None else "nl"  # LJ method used either distance matrix or neighbor list
    info_for_naming = params_tostring(p)

    header = "Starting at {t}".format(t=time_now())
    print header
    print "-" * len(header)
    print "running with", info_for_naming

    # Get the initial problem container and meta
    init_container, p.y_funnel_bottom, p.anchor_ixs = problems.hourglass(**p.__dict__)
    p.num_grains = init_container.num_particles - len(p.anchor_ixs)

    # Boundary so particles keep recirculating
    # Need to have enough x space that grains and anchors don't init on top of each other
    posns = init_container.positions
    xl, yb = np.min(posns, axis=0)  # left, bottom
    xr, yt = np.max(posns, axis=0)  # right, top
    xlim, ylim = [(xl - p.diam, xr + p.diam), (yb - 2 * p.diam, yt + p.diam)]
    if p.use_bounds:
        init_container.bounds = [xlim, ylim]

    forces = [
        problems.GravityForce(g=p.gravity_magnitude),
        problems.LJRepulsiveAndDampingForce(cutoff_dist=p.diam, viscous_damping_magnitude=p.viscous_damping_magnitude),
        problems.FakeStatsForce(),
    ]

    w = distance(*xlim)
    h = distance(*ylim)
    a_ratio = w / h
    # figsize must be integers or animation will error saving to file!
    fh = int(figheight)
    figsize = (int(a_ratio * fh) + 1, fh)

    containers = [init_container]

    integrator = VerletIntegrator()
    integrator.sim_wide_params = p
    integrator.forces = forces

    run_func = RunFunc(p)

    graphical.animate_with_live_integration(
        containers,
        integrator,
        dt,
        xlim,
        ylim,
        figsize,
        particle_radius,
        frame_show_modulus,
        num_frames_to_bootstrap,
        info_for_naming,
        save_animation,
        show_animation,
        run_func,
        anim_save_kwargs=anim_save_kwargs,
        sim_wide_params=p,
    )

    stats = problems.SimStats(info_for_naming, containers, p)
    lstats.append(stats)

    if p.dump_data:
        stats.write_csvs(p.data_dump_modulus)
        stats.write_plots(p.data_dump_modulus, show=False)
    # graphical.plot_sand(stats.times, stats.???, gravity_magnitude=stats.gravity_magnitude, info_for_naming=info_for_naming, show=False)

    print "all params:", p