Exemplo n.º 1
0
from gsurface import Tyi
from gsurface.advanced.structure import BowStructure, SurfaceGuidedStructureSystem
from gsurface.forces import ViscousFriction
from gsurface.plotter import mayavi_plot_surfaces, SurfacePlot
from gsurface.plotter.colors import rgb
from gsurface.surface import Tore

from gsurface.serialize import save_attached

from gsurface.tools import nprand

SIZE = 5

surface = Tore(0.5, 1.0)
mesh = surface.build_surface(*surface.mesh(50, 50))

snake = BowStructure(SIZE, 1.0, stiffness=1000.0, mu=10.0, l0=1.0)

snake.interactions[(0, SIZE - 1)].stiffness = 100.0

sim = SurfaceGuidedStructureSystem(surface, snake, s0=nprand(4*SIZE), structureForces=[
    ViscousFriction(0.01)
])

sim.s0[1::4] = 1.0

time = np.linspace(0, 40, 1000)

data = sim.solve(time)
Exemplo n.º 2
0
from gsurface.surface import Tore, EggBox
from gsurface.forces import SpringInteraction, Gravity, ViscousFriction
from gsurface.plotter import mayavi_plot_surfaces, matplotlib_plot_solutions, SurfacePlot
from gsurface import SurfaceGuidedInteractedMassSystems, SurfaceGuidedMassSystem, Tyi, build_s0

import numpy as np

# queue of N solids, attached with a spring

SYSTEMS = 8

stiffness = 10

tore = Tore(0.5, 1.0)
tore_mesh = tore.build_surface(*tore.mesh(50, 50))

# build model
joint_sim = SurfaceGuidedInteractedMassSystems([
    SurfaceGuidedMassSystem(surface=tore,
                            s0=build_s0(0, 2 * j, 0.0, 1 + j),
                            m=1.0,
                            forces=[
                                ViscousFriction(0.2),
                                Gravity(1.0, np.array([0.0, 0.0, -1.0]))
                            ]) for j in range(SYSTEMS)
], {(i, i + 1): SpringInteraction(1.0)
    for i in range(SYSTEMS - 1)})

time = np.linspace(0, 25, 2000)

data = joint_sim.solve(time)
Exemplo n.º 3
0
import time as timelib

from gsurface.forces import Gravity, ViscousFriction
from gsurface.forces.interaction import OneSideSpringInteraction
from gsurface.imodel import *
from gsurface.indexes import Tyi
from gsurface.model import build_s0
from gsurface.plotter.mayavi import mlab, mayavi_plot_surfaces, SurfacePlot
from gsurface.surface import Sphere, Tore, Plan

# objects
sphere = Sphere(0.8).translate(np.array([0.0, 0.0, 0.0]))
mesh_sphere = sphere.build_surface(*sphere.mesh(50, 50))

tore = Tore(r=0.5, R=2.0).translate(np.array([0.0, 0.0, 0.0]))
mesh_tore = tore.build_surface(*tore.mesh(50, 50))

plan_shift = np.array([0.0, 0.0, -1.0])
plan = Plan.from_xz_rotation(np.pi / 2 * 0.1).translate(plan_shift).setlims(
    v_ll=-4, v_ul=4, u_ll=-4, u_ul=4)
mesh_plan = plan.build_surface(*plan.mesh(50, 50))

gravity_vector = np.array([0.0, 0.0, -10.0])

tore_sim = SurfaceGuidedMassSystem(surface=tore,
                                   s0=build_s0(v0=np.pi / 2, du0=3.0),
                                   m=1.0)

sphere_sim = SurfaceGuidedMassSystem(
    surface=sphere,
    s0=build_s0(v0=np.pi / 2, dv0=2),