Esempio n. 1
0
import numpy as np

from gsurface.forces import Gravity, ViscousFriction, SpringForce, LengthedSpringForce
from gsurface.model import SurfaceGuidedMassSystem, build_s0
from gsurface.advanced.structure import SurfaceGuidedStructureSystem, TriangleStructure, BowStructure, CarStructure, SnakeStructure
from gsurface.surface import Sphere, Tore

# setup simulation for tore
tore = Tore(r=0.5, R=1.0).translate(np.array([3.0, 0.0, 0.0]))

tore_sim = SurfaceGuidedMassSystem(
    surface=tore,
    s0=build_s0(du0=10.0),
    m=1.0,
    forces=[Gravity(1.0, np.array([0.0, 0.0, -9.0])),
            ViscousFriction(0.5)])

# setup simulation for sphere
sphere = Sphere(1.0)

sphere_sim = SurfaceGuidedMassSystem(
    surface=sphere,
    s0=build_s0(u0=1.5, du0=10.0, v0=1.5),
    m=1.0,
    forces=[Gravity(1.0, np.array([0.0, 0.0, 9.0])),
            ViscousFriction(0.5)])

tore_sim2 = SurfaceGuidedMassSystem(
    surface=Tore(0.5, 1.0),
    s0=build_s0(u0=0.0, du0=0.5, v0=1.0, dv0=0.0),
    m=1.0,
Esempio n. 2
0
import numpy as np

from gsurface import Tyi
from gsurface.forces import Gravity, ViscousFriction
from gsurface.model import SurfaceGuidedMassSystem, build_s0
from gsurface.plotter import mayavi_plot_surfaces, SurfacePlot, mlab
from gsurface.plotter.matplotlib import matplotlib_plot_solutions
from gsurface.surface import EllipticParaboloid, HyperbolicParaboloid

# choose between elliptic or hyperbolic paraboloid surface
surface_class = EllipticParaboloid

if surface_class is HyperbolicParaboloid:
    para = HyperbolicParaboloid(1.0, 5).setlims(v_ul=10)
    s0 = build_s0(u0=0.0, v0=1.0, du0=3)
else:
    para = EllipticParaboloid(1.0, 1.0)
    s0 = build_s0(u0=0.0, v0=1.0, du0=2)

surface = para.build_surface(*para.mesh(50, 50))

# check surface definition
print(para, para.check(20, 20))

# create model
model = SurfaceGuidedMassSystem(surface=para,
                                s0=s0,
                                m=1.0,
                                forces=[
                                    Gravity(m=1.0, g=np.array([0.0, 0.0, -2])),
Esempio n. 3
0
# electron
#  https://fr.wikipedia.org/wiki/%C3%89lectron
me = 9.109e-31  # kg
qe = -1.602e-19  # C

# proton
#  https://fr.wikipedia.org/wiki/Proton
mp = 1.672e-27  # kg
qp = -qe  # C

E = np.array([0.0, U / d, 0.0])  # V/m
B = np.array([0.0, 0.0, 8.0e-2])  # T

model = SurfaceGuidedMassSystem(surface=plan,
                                s0=build_s0(u0=0.0, du0=2.0e6),
                                m=mp,
                                forces=[
                                    StaticFieldElectroMagneticForce(
                                        q=qp,
                                        E=E,
                                        B=None,
                                    ),
                                ])

T = np.linspace(0.0, 1.0e-4, 1000)

states = model.solve(T)

solutions = model.solutions(states, T)
Esempio n. 4
0
# 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),
    m=1.0,
    forces=[Gravity(1.0, gravity_vector),
            ViscousFriction(1.0)])

plan_sim = SurfaceGuidedMassSystem(
    surface=plan,
    s0=build_s0(u0=4.0, v0=2),
    m=1.0,
    forces=[
        # Gravity(1.0, gravity_vector),
Esempio n. 5
0
from gsurface.model import SurfaceGuidedMassSystem, build_s0, Tyi
from gsurface.plotter import mayavi_plot_surfaces, SurfacePlot, mlab
from gsurface.surface import Plan

angle = 0.1 * np.pi / 2  # np.pi/2

plan = Plan(1.0, 0.0, 0.0).rotate(
    Rotation.from_rotvec(np.array([np.pi, 0.0, 0.0])).as_matrix())
# plan = Plan.from_rotations(0.0, np.pi, 0.0) # equivalent définition

plan.shiftvector = np.array([0.0, 0.0, 1.0])

surface = plan.build_surface(*plan.mesh(50, 50))

model = SurfaceGuidedMassSystem(surface=plan,
                                s0=build_s0(0.5, 0.0, 0.0, 0.0),
                                m=1.0,
                                forces=[
                                    Gravity(m=1.0,
                                            g=np.array([0.0, 0.0, -10.0])),
                                    SpringDampingForce(stiffness=1000.0,
                                                       mu=10.0,
                                                       clip=np.array(
                                                           [0.0, 0.0, 0.0]),
                                                       l0=0.5),
                                    ViscousFriction(mu=0.5)
                                ])

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

states = model.solve(time)