Example #1
0
def u_next_lax_wendroff(u_last, u_halfstep, delta_t, delta_x, j, time,
                        position):
    u_halfstep[j] = u_next_half_step(u_last, delta_t, delta_x, j, time,
                                     position)
    return u_last[j] - delta_t/delta_x*(func.f(u_halfstep[j])-func.f(u_halfstep[j-1])) \
           + delta_t*func.g(u_halfstep, delta_x, j)\
           + delta_t/2*(func.s(time, position, u_halfstep, j)\
           + func.s(time, position, u_halfstep, j-1))
Example #2
0
    def forward_step(self, x):
        """Return z_k = g(a_k, a_k+1) values for this layer (as a vector)"""

        a_q = self.layer_output(x)

        # Apply transfer function
        a_q_even = a_q[::2]
        a_q_odd = a_q[1::2]
        z = func.g(a_q_even, a_q_odd)
        assert len(z) == self.h, "Invalid size of output vector (z)"
        return z
Example #3
0
def test_g():
    g()
Example #4
0
def u_next_upwind(u_last, delta_t, delta_x, j, time, position):
    return u_last[j] - delta_t/delta_x*(func.f(u_last[j])-func.f(u_last[j-1])) \
           + delta_t*func.g(u_last, delta_x, j)\
           + delta_t*func.s(time, position, u_last, j)
Example #5
0
def u_next_half_step(u_last, delta_t, delta_x, j, time, position):
    return (u_last[j+1] + u_last[j] - delta_t /delta_x*(func.f(u_last[j+1]) - func.f(u_last[j])) \
           + delta_t*func.g(u_last, delta_x, j)
           + delta_t/2*(func.s(time, position, u_last, j+1)+func.s(time, position, u_last, j)))/2
Example #6
0
def u_approx_mac_cormack(u_last, delta_t, delta_x, j, time, position):
    return u_last[j] - delta_t/delta_x*(func.f(u_last[j]) - func.f(u_last[j-1])) \
               + delta_t*func.g(u_last, delta_x, j)\
               + delta_t*func.s(time, position+delta_x, u_last, j)
Example #7
0
def u_next_mac_cormack(u_last, u_approx, delta_t, delta_x, j, time, position):
    return (u_approx[j]+u_last[j]- (delta_t)/(2*delta_x)*(func.f(u_approx[j+1])- func.f(u_approx[j]))\
            + delta_t*func.g(u_approx, delta_x, j)\
            + delta_t*func.s(time, position, u_approx, j))/2