def test_linear2(self):
     U = (1, 2, 3, 4, 5)
     d1 = 2
     d2 = 2
     fractal = [at.w(U, d1, d2, 3)(i) for i in [1, 3]]
     self.assertAlmostEqual(U[1], fractal[0](0.5))
     self.assertAlmostEqual(U[3], fractal[1](0.5))
 def test_constant(self):
     U = (1, 1, 1, 1, 1)
     d1 = 2
     d2 = 2
     fractal = [at.w(U, d1, d2, 1)(i) for i in [1, 2]]
     self.assertAlmostEqual(U[1], fractal[0](0.5))
     self.assertAlmostEqual(U[1], fractal[1](0.5))
Ejemplo n.º 3
0
def draw_interpolation_scheme():

    d1 = 2**(-1 / 3)
    d2 = -2**(-1 / 3)

    d1_1 = 2**(-1 / 5)
    d2_1 = -2**(-1 / 5)

    d1_2 = 2**(-1 / 11)
    d2_2 = -2**(-1 / 11)

    w3_13 = fractal_interpolation(at.w(UFX_SHORT, d1, d2, 3), len(UFX_SHORT))
    w3_17 = fractal_interpolation(at.w(UFX_SHORT, d1_2, d2_2, 3),
                                  len(UFX_SHORT))
    w3_15 = fractal_interpolation(at.w(UFX_SHORT, d1_1, d2_1, 3),
                                  len(UFX_SHORT))
    label = {
        0: '$|d_{i}| = 2^{-1/3}$',
        1: '$|d_{i}| = 2^{-1/5}$',
        2: '$|d_{i}| = 2^{-1/11}$'
    }

    draw_fractal('stretching_factors.pdf', w3_13, w3_15, w3_17, label=label)
Ejemplo n.º 4
0
def run_project(args):

    opt = options.Options()

    parsed_args = opt.parse(args[1:])

    y = parsed_args.slice_yplus

    d1 = 2**(-1 / 3)
    d2 = -2**(-1 / 3)

    w3_LES = fractal_interpolation(at.w(Ufx, d1, d2, 3), len(Ufx))
    w3_from_resampled = fractal_interpolation(at.w(Ux_resampled, d1, d2, 3),
                                              len(Ufx))
    label = {0: '$W^{3}$: filtered DNS', 1: '$W^{3}$: resampled DNS'}

    draw_fractal('LES_and_resampled.pdf',
                 w3_LES,
                 w3_from_resampled,
                 label=label)
    draw_fractal('LES_and_DNS.pdf')

    ek = kinetic_energy(Ux, Ufx, Ux_resampled, w3_LES['y'],
                        w3_from_resampled['y'])
    fft = fourier_transform(Ux, Ufx, Ux_resampled, w3_LES['y'],
                            w3_from_resampled['y'])

    plt.figure(figsize=(8, 4))
    sns.violinplot(data=list(fft.values())[:3])
    plt.xticks(plt.xticks()[0], fft.keys())
    plt.tight_layout()
    plt.savefig("fractal_violinplot_ftt.pdf")

    for_box = {
        'DNS': Ux,
        'filtered DNS': Ufx,
        '$W^{3}$: filtered': w3_LES['y'],
        'resampled DNS': Ux_resampled,
        '$W^{3}$: resampled': w3_from_resampled['y']
    }

    colors = {
        i: v
        for i, v in enumerate(
            ['lightgrey', 'lightgrey', 'darkorange', 'lightgrey', 'slateblue'])
    }
    plt.figure(figsize=(8, 4))
    sns.violinplot(data=list(for_box.values()),
                   orient='v',
                   palette=colors,
                   inner='quartile',
                   bw='silverman')
    plt.xticks(plt.xticks()[0], for_box.keys())
    plt.tight_layout()
    plt.savefig("fractal_violinplot.pdf")

    plt.figure(figsize=(8, 4))
    sns.boxplot(data=list(for_box.values()))
    plt.xticks(plt.xticks()[0], for_box.keys())
    plt.tight_layout()
    plt.savefig("fractal_boxplot.pdf")
 def test_w1_u0_1(self):
     U = (1, 4, 3)
     d1 = 2
     d2 = 2
     fractal = at.w(U, d1, d2, 1)(1)
     self.assertAlmostEqual(fractal(0.5), 4)
 def test_u0(self):
     U = (1, 4, 3)
     d1 = 1
     d2 = 1
     fractal = at.w(U, d1, d2, 0)(1)
     self.assertAlmostEqual(fractal(0.5), 2)
 def test_constant(self):
     U = (1, 1, 1)
     d1 = 1
     d2 = 1
     fractal = at.w(U, d1, d2, 1)(1)
     self.assertAlmostEqual(U[1], fractal(0.5))