Beispiel #1
0
def test_X2():
    x = Variable("x")
    E = Energy(x**2)
    L = Lagrangian(E)
    Lvec = L.get()

    assert Lvec.shape == (1, )
    assert Lvec[0] == -2 * x
Beispiel #2
0
def test_XdX():
    x = Variable("x")
    dx = x.dt
    E = Energy(x * dx)
    L = Lagrangian(E)
    Lvec = L.get()

    assert Lvec.shape == (1, )
    assert Lvec[0] == 0
Beispiel #3
0
def test_dX2():
    x = Variable("x")
    dx = x.dt
    ddx = x.ddt
    E = Energy(dx**2)
    L = Lagrangian(E)
    Lvec = L.get()

    assert Lvec.shape == (1, )
    assert Lvec[0] == 2 * ddx
Beispiel #4
0
def test_cosX():
    x = Variable("x")
    f = cos(x)
    df = -1 * sin(x)

    E = Energy(f)
    L = Lagrangian(E)
    Lvec = L.get()

    assert Lvec.shape == (1, )
    assert Lvec[0] == -1 * df
Beispiel #5
0
    def __init__(self, E, IC, G, F, timesteps):
        Validation_Solver.init(self, E, IC, G, F, timesteps)
        if not isinstance(E, Energy):
            E = Energy(E)
        lagrange = Lagrangian(E)
        self.X = E.X

        self.timesteps = timesteps

        self.n = len(self.X)
        self.m = len(G)
        self.__computeG(G)
        self.__computeDG()
        self.__computeDDG()
        self.__computeM(lagrange)
        self.__computeC(lagrange)
        self.__computeK(lagrange)
        self.__computeZ(lagrange)
        self.__computeMvv(lagrange)
        self.__computeMvp(lagrange)
        self.__computeMpp(lagrange)
        self.__resetAllMatrix()
        self.__computeF(F)
        self.__computet0()
        self.__computeX0(IC)
        self.__computedX0(IC)
Beispiel #6
0
def test_Constant():
    E = Energy(1)
    L = Lagrangian(E)
    Lvec = L.get()

    assert Lvec is None