Ejemplo n.º 1
0
def matrix(dt, dx, rho, Cv, k_t):
    Idx = tt.eye(2, 3*dx) # identity tensor
    Idt = tt.eye(2, dt)
    
    delta = tt.qlaplace_dd([dx, dx, dx]) # laplasian
    
    support =  tt.delta(2, dt, center = 1) # first time derivative
    deriv = tt.Toeplitz(support,kind='L') - tt.Toeplitz(support,kind='L').T
    deriv = deriv.round(1e-6)
    
    return rho * Cv * tt.kron(Idx, deriv) - k_t * tt.kron(delta, Idt)
Ejemplo n.º 2
0
#%%
from __future__ import print_function, absolute_import, division
import sys
sys.path.append('../')
import tt
from tt.amen import amen_solve
""" This program test two subroutines: matrix-by-vector multiplication
    and linear system solution via AMR scheme"""

d = 12
A = tt.qlaplace_dd([d])
x = tt.ones(2,d)
y = amen_solve(A,x,x,1e-6)

#%%

c = tt.multifuncrs2([a, b], lambda x: np.sum(x, axis=1), eps=1E-6)

y = amen_solve(A,x,x,1e-6)


# %%
y
# %%
A
# %%
x
# %%
z=tt.matvec(A,x)
# %%
z
Ejemplo n.º 3
0
import numpy as np
from math import pi,sqrt
import tt
from tt.ksl import ksl
import time
from scipy.linalg import expm
d = 6
f = 1
A = tt.qlaplace_dd([d]*f)
n = [2]*(d*f)
n0 = 2**d
x = np.arange(1,n0+1)*1.0/(n0+1)
x = np.exp(-10*(x-0.5)**2)
x = tt.tensor(x.reshape([2]*d,order='F'),1e-8)
#x = tt.ones(2,d)
tau = 1
tau1 = 1
y = x.copy()
ns_fin = 8
tau0 = 1.0
tau_ref = tau0/2**ns_fin
for i in xrange(2**ns_fin):  
    y=ksl(-1.0*A,y,tau_ref)
yref = y.copy()
tau = 5e-2
res = ""
ns = 2
while ( ns <= ns_fin ):
    tau = tau0/(2**ns) 
    y = x.copy()
    for i in xrange(2**ns):
Ejemplo n.º 4
0
def matrix(dx, rho, Cv, k_t):
    Idx = tt.eye(2, 3*dx) # identity tensor
    
    delta = tt.qlaplace_dd([dx, dx, dx]) # laplasian
    
    return - k_t/(rho*Cv) * delta
Ejemplo n.º 5
0
import numpy as np
from math import pi,sqrt
import tt
from tt.ksl import ksl
import time
from scipy.linalg import expm
d = 6
f = 1
A = tt.qlaplace_dd([d]*f)*((2**d+1))**2
#A = tt.eye(2,d)
n = [2]*(d*f)
n0 = 2**d
t = np.arange(1,n0+1)*1.0/(n0+1)
x = np.exp(-20*(t-0.5)**2)
#x = np.sin(sqrt(2.0)*pi*t)
x = tt.tensor(x.reshape([2]*d,order='F'),1e-2)
#x = tt.ones(2,d)
#x = x + 0 * tt.rand(2,d,2)
tau = 1
tau1 = 1
y = x.copy()
ns_fin = 8
tau0 = 1.0
tau_ref = tau0/2**ns_fin
import matplotlib.pyplot as plt
plt.ion()
fig = plt.figure()
ax = fig.add_subplot(111)
#tau_ref = 0.0
line1, = ax.plot(np.real(y.full().flatten("F")))
ax.hold("True")