コード例 #1
0
def Rn(Tn: np.array, Cn: np.array, dims: int = 3) -> np.array:

    #Define quantites for clarity
    lap = sn.filters.laplace(Tn) / (co.dx**2)
    watervel = func.u_w(Tn, Cn)
    gradT = np.array(np.gradient(Tn, co.dx))
    stationary = -co.k_m * lap + co.rho_w * co.cp_w * func.dotND(
        watervel, gradT)

    #Calculate T in the bulk
    T = -stationary / (co.rho_m * co.cp_m)

    #Well defined for square beef
    #slice 0 = lowest value ('bottom'), slice -1 = highest value ('top')
    #axis 0 = x, axis 1 = y, axis 2 = z
    #Assumes that T_surf is the unknown in the next time step
    def R_boundary(slice_index: int, axis_index: int):
        if slice_index == 0 or slice_index == -1:
            #Take the correct 2d arrays of relevant quantities
            T_b = Tn.take(indices=slice_index, axis=axis_index)
            grad_b = gradT[axis_index].take(indices=slice_index,
                                            axis=axis_index)
            watervel_b = watervel[axis_index].take(indices=slice_index,
                                                   axis=axis_index)
        else:
            raise IndexError(
                'Accessing the boundary requires a boundary slice index (0 or -1)'
            )

        return co.T_oven - 1 / ((1 - co.f) * co.h) * (
            co.k_m * grad_b + watervel_b * co.cp_w * co.rho_w * T_b)

    #Enforce boundary condition with a python hack
    for i in range(dims):
        a = [slice(None)] * T.ndim
        a[i] = 0
        b = [slice(None)] * T.ndim
        b[i] = -1
        # Enforce the calculated boundary condition
        T[tuple(a)] = R_boundary(0, i)
        T[tuple(b)] = R_boundary(-1, i)

    return T
コード例 #2
0
ファイル: C_conf.py プロジェクト: waffelroffel/BeefSimulator
def C_uw(T, C, I, J, K, dh):
    u = u_w(T.reshape((I, J, K)), C.reshape((I, J, K)), dh)
    return np.zeros_like(u.reshape((3, -1)).T)
コード例 #3
0
def C_uw(T, C, I, J, K, dh):
    u = u_w(T.reshape((I, J, K)), C.reshape((I, J, K)), dh)
    return u.reshape((3, -1)).T
コード例 #4
0
ファイル: 1Dmodel.py プロジェクト: waffelroffel/BeefSimulator
def T_next(T_prev: np.array, C_prev: np.array) -> np.array:
    return 1/(co.rho_m*co.cp_m) * (co.k_m*sn.filters.laplace(T_prev)/co.dx**2 - co.rho_w*co.cp_w*func.u_w(T_prev, C_prev)*np.gradient(T_prev, co.dx))
コード例 #5
0
ファイル: 1Dmodel.py プロジェクト: waffelroffel/BeefSimulator
def C_next(T_prev: np.array, C_prev: np.array) -> np.array:
    return co.D*np.gradient(C_prev, co.dx)**2 - np.gradient(C_prev * func.u_w(T_prev, C_prev), co.dx)
コード例 #6
0
def targetGenerator():
    return


"""
Solve system:
[[B C 0 .           0]
 ...
 [0 .. 0 A B C 0 .. 0]
 ...
 [0       ..    0 A B]]
"""

# dimensions

x = 3
y = 3
z = 3
t = 3
h = 0.1

# main

Tn = initialCondTemp(np.zeros(x * y * z))
Cn = initialCondWater(np.zeros(x * y * z))
speed = af.u_w(Tn, Cn)
print(matrixGenerator())

# for i in range(t):
#    speed = af.u_w
コード例 #7
0
def T_uw(T, C, I, J, K, dh):
    u = u_w(T.reshape((I, J, K)), C.reshape((I, J, K)), dh)
    # temporary way to decouple the equation
    return np.ones(u.reshape((3, -1)).T.shape)
コード例 #8
0
def Sn(Tn: np.array, Cn: np.array) -> np.array:
    lap = sn.filters.laplace(Cn) / (co.dx**2)
    v = Cn * func.u_w(Tn, Cn)
    return co.D * lap - func.div(v, co.dx)