def test_jacobian(): from test_ginzburg_landau import GinzburgLandau a = 10.0 n = 10 points, cells = meshzoo.rectangle(-a / 2, a / 2, -a / 2, a / 2, n, n) mesh = meshplex.MeshTri(points, cells) gl = GinzburgLandau(mesh) glr = GinzburgLandauReal(mesh) n = points.shape[0] numpy.random.seed(123) for _ in range(10): psi = numpy.random.rand(n) + 1j * numpy.random.rand(n) mu = numpy.random.rand(1)[0] jac0 = gl.jacobian(psi, mu) jac1 = glr.jacobian(to_real(psi), mu) for _ in range(10): phi = numpy.random.rand(n) + 1j * numpy.random.rand(n) out0 = (jac0 * phi) * mesh.control_volumes out1 = to_complex(jac1 * to_real(phi)) assert numpy.all(numpy.abs(out0 - out1) < 1.0e-12)
def test_jacobian(): from test_ginzburg_landau import GinzburgLandau a = 10.0 n = 10 points, cells = meshzoo.rectangle_tri((-a / 2, -a / 2), (a / 2, a / 2), n) # add column with zeros for magnetic potential points = np.column_stack([points, np.zeros(points.shape[0])]) mesh = meshplex.MeshTri(points, cells) gl = GinzburgLandau(mesh) glr = GinzburgLandauReal(mesh) n = points.shape[0] np.random.seed(123) for _ in range(10): psi = np.random.rand(n) + 1j * np.random.rand(n) mu = np.random.rand(1)[0] jac0 = gl.jacobian(psi, mu) jac1 = glr.jacobian(to_real(psi), mu) for _ in range(10): phi = np.random.rand(n) + 1j * np.random.rand(n) out0 = (jac0 * phi) * mesh.control_volumes out1 = to_complex(jac1 * to_real(phi)) assert np.all(np.abs(out0 - out1) < 1.0e-12)
def test_df_dlmbda(): from test_ginzburg_landau import GinzburgLandau a = 10.0 n = 10 points, cells = meshzoo.rectangle_tri(np.linspace(-a / 2, a / 2, n), np.linspace(-a / 2, a / 2, n)) # add column with zeros for magnetic potential points = np.column_stack([points, np.zeros(points.shape[0])]) mesh = meshplex.Mesh(points, cells) gl = GinzburgLandau(mesh) glr = GinzburgLandauReal(mesh) n = points.shape[0] np.random.seed(123) for _ in range(10): psi = np.random.rand(n) + 1j * np.random.rand(n) mu = np.random.rand(1)[0] out = gl.df_dlmbda(psi, mu) * mesh.control_volumes out2 = glr.df_dlmbda(to_real(psi), mu) assert np.all(np.abs(out - to_complex(out2)) < 1.0e-12)
def test_df_dlmbda(): from test_ginzburg_landau import GinzburgLandau a = 10.0 n = 10 points, cells = meshzoo.rectangle(-a / 2, a / 2, -a / 2, a / 2, n, n) mesh = meshplex.MeshTri(points, cells) gl = GinzburgLandau(mesh) glr = GinzburgLandauReal(mesh) n = points.shape[0] numpy.random.seed(123) for _ in range(10): psi = numpy.random.rand(n) + 1j * numpy.random.rand(n) mu = numpy.random.rand(1)[0] out = gl.df_dlmbda(psi, mu) * mesh.control_volumes out2 = glr.df_dlmbda(to_real(psi), mu) assert numpy.all(numpy.abs(out - to_complex(out2)) < 1.0e-12)