Exemplo n.º 1
0
def compute_dt_matrices(A, B, h, TV=False):
    # variable declaration
    t0 = 0.0  # start time
    T = 1  # end time
    n, m = B.shape

    # Matrix declaration
    x0 = np.random.random(n)
    Csurface = np.random.random((m, n))

    # Declaration of the Dynamical System
    if TV:
        process_ds = SK.FirstOrderLinearDS(x0, A)
    else:
        process_ds = SK.FirstOrderLinearTIDS(x0, A)
    # Model
    process = SK.Model(t0, T)
    process.nonSmoothDynamicalSystem().insertDynamicalSystem(process_ds)
    # time discretisation
    process_time_discretisation = SK.TimeDiscretisation(t0, h)
    # Creation of the Simulation
    process_simu = SK.TimeStepping(process_time_discretisation, 0)
    process_simu.setName("plant simulation")
    # Declaration of the integrator
    process_integrator = SK.ZeroOrderHoldOSI()
    process_integrator.insertDynamicalSystem(process_ds)
    process_simu.insertIntegrator(process_integrator)

    rel = SK.FirstOrderLinearTIR(Csurface, B)
    nslaw = SK.RelayNSL(m)
    inter = SK.Interaction(m, nslaw, rel)

    #process.nonSmoothDynamicalSystem().insertInteraction(inter, True)
    process.nonSmoothDynamicalSystem().link(inter, process_ds)
    process.nonSmoothDynamicalSystem().setControlProperty(inter, True)
    # Initialization
    process.initialize(process_simu)

    # Main loop
    process_simu.computeOneStep()
    Ad = SK.getMatrix(process_integrator.Ad(process_ds)).copy()
    Bd = SK.getMatrix(process_integrator.Bd(process_ds)).copy()

    return (Ad, Bd)
Vinit = 1.0
theta = 0.5
N = int((T - t0) / h)

# Dynamical systems
A = np.zeros((2, 2))
x0 = np.array([Vinit, -Vinit])
B = 2.0 * np.eye(2)
C = np.eye(2)
D = np.zeros((2, 2))

process = sk.FirstOrderLinearDS(x0, A)
process.setComputebFunction('plugins', 'computeB')

# Interactions
myNslaw = sk.RelayNSL(2)
myProcessRelation = sk.FirstOrderLinearR(C, B)
myProcessRelation.setComputeEFunction('plugins', 'computeE')
# myProcessRelation.setDPtr(D)

myProcessInteraction = sk.Interaction(myNslaw, myProcessRelation)

# NSDS
simplerelay = sk.NonSmoothDynamicalSystem(t0, T)
simplerelay.insertDynamicalSystem(process)
simplerelay.link(myProcessInteraction, process)

# myProcessRelation.computeJachx(0, x0, x0 , x0, C)

# Simulation
s = sk.TimeStepping(simplerelay, sk.TimeDiscretisation(t0, h),
Exemplo n.º 3
0
# r = B.lambda
ninter = 2
B = np.zeros((ndof, ninter), dtype=np.float64)
B[0, 0] = -alpha * 0.5
B[0, 1] = 1 + alpha * 0.5
B[1, 0] = -B[0, 1]
B[1, 1] = B[0, 0]
B[2, 0] = gamma * 0.5
B[2, 1] = gamma * 0.5

C = np.zeros((ninter, ndof), dtype=np.float64)
C[0, 0] = C[1, 1] = -1.

particle_relation = sk.FirstOrderLinearR(C, B)

nslaw = sk.RelayNSL(ninter)

particle_interaction = sk.Interaction(nslaw, particle_relation)

# -- The Model --
filippov = sk.Model(t0, T)
nsds = filippov.nonSmoothDynamicalSystem()
nsds.insertDynamicalSystem(particle)
nsds.link(particle_interaction, particle)

# -- Simulation --
td = sk.TimeDiscretisation(t0, h)
simu = sk.TimeStepping(td)
# osi
theta = 0.5
myIntegrator = sk.EulerMoreauOSI(theta)