-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy path_test_lagham.py
30 lines (25 loc) · 1.02 KB
/
_test_lagham.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# Copyright 2020-2025 Francesco Biscani ([email protected]), Dario Izzo ([email protected])
#
# This file is part of the heyoka.py library.
#
# This Source Code Form is subject to the terms of the Mozilla
# Public License v. 2.0. If a copy of the MPL was not distributed
# with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
import unittest as _ut
class lagham_test_case(_ut.TestCase):
def test_basic(self):
# Just some basic testing for the keyword arguments.
from . import lagrangian, hamiltonian, make_vars, cos, sin, expression
x, v, p = make_vars("x", "v", "p")
L = 0.5 * v**2 - (1.0 - cos(x))
sys = lagrangian(L=L, qs=[x], qdots=[v], D=expression(0.0))
self.assertEqual(sys, [(x, v), (v, -sin(x))])
H = p * p / 2.0 + (1.0 - cos(x))
sys = hamiltonian(H=H, qs=[x], ps=[p])
self.assertEqual(
sys,
[
(x, (0.50000000000000000 * (p + p))),
(p, -(-(-sin(x)))),
],
)