파일:Heat.gif

testwiki
둘러보기로 이동 검색으로 이동
    원본 파일 (1,200 × 954 픽셀, 파일 크기: 2.66 MB, MIME 종류: image/gif, 반복됨, 30 프레임, 3.0초)
    참고: 기술적인 제한으로 인해 고해상도 GIF 그림 섬네일은 애니메이션을 지원하지 않습니다.

    이 파일은 위키미디어 공용에 있으며, 다른 프로젝트에서 사용하고 있을 가능성이 있습니다. 해당 파일에 대한 설명이 아래에 나와 있습니다.

    파일 설명

     이 GIF 컴퓨터 그래픽스는 Python(으)로 제작되었습니다.
    설명
    English: Illustration of the Heat equation with a crescent moon as initial condition.
    날짜
    출처 자작
    저자 Nicoguaro. Based on File:Heat eqn.gif by en:User:Oleg Alexandrov
    다른 버전
    소스 코드
    InfoField

    Python code

    """
    Illustration of the heat equation
    
    Solve the heat equation using finite differences and Forward Euler.
    
    Based on: https://commons.wikimedia.org/wiki/File:Heat_eqn.gif
    """
    
    from __future__ import division, print_function
    import numpy as np
    from mayavi import mlab
    import subprocess
    
    path_to_convert = "C:\Program Files\ImageMagick-6.9.3\convert.exe"
    
    def step_function(N, scale, X, Y, shape="crescent"):
        """Function that is 1 on a set and 0 outside of it"""
        shapes = ["crescent", "cylinder", "hexagon", "superquadric", "smiley"]
        
        if shape not in shapes:
            shape = "crescent"
    
        if shape == "cylinder":
            Z = np.ones_like(X)
            Z[X**2 + Y**2 < 0.5] = 0
            Z[X**2 + Y**2 > 2] = 0
    
        if shape == "superquadric":
            Z = np.ones_like(X)
            Z[np.abs(X)**0.5 + np.abs(Y)**0.5 > 1.5] = 0
    
        if shape == "hexagon":
            Z = np.ones_like(X)
            hexa = 2*np.abs(X) + np.abs(X - Y*np.sqrt(3)) +\
                np.abs(X + Y*np.sqrt(3))
            Z[hexa > 6] = 0
    
        if shape == "crescent":
            c = 2
            d = -1
            e = 1
            f = 0.5
            k = 1.2
            shift = 10        
            Z = (c**2 - (X/e - d)**2 - (Y/f)**2)**2 + k*(c + d - X/e)**3 - shift
            Z = 1 - np.maximum(np.sign(Z), 0)
            
        if shape == "smiley":
            Z = np.ones_like(X)
            fac = 1.2
            x_eye = 0.5
            y_eye = 0.4
            bicorn = fac**2*(Y + 0.3)**2*(1 - fac**2*X**2) -\
                    (fac**2*X**2 - 2*fac*(Y + 0.3) - 1)**2
            left_eye = (X + x_eye)**2/0.1 + (Y - y_eye)**2/0.4 - 1
            right_eye = (X - x_eye)**2/0.1 + (Y - y_eye)**2/0.4 - 1
            Z[X**2 + Y**2 > 2] = 0
            Z[bicorn > 0] = 0
            Z[left_eye < 0] = 0
            Z[right_eye < 0] = 0
    
        Z = scale * Z
        return Z
    
    def data_gen(num):
        # Solve the heat equation with zero boundary conditions
        for cont in range(ntime_anim):
            Z[1:N-1, 1:N-1] = Z[1:N-1, 1:N-1] + dt*(Z[2:N, 1:N-1] +
                                 Z[0:N-2, 1:N-1] + Z[1:N-1, 0:N-2] +
                                 Z[1:N-1, 2:N] - 4*Z[1:N-1, 1:N-1])/dx**2
    
        surf = mlab.surf(X, Y, Z, colormap='autumn', warp_scale=1)
        # Change the visualization parameters.
        surf.actor.property.interpolation = 'phong'
        surf.actor.property.specular = 0.3
        surf.actor.property.specular_power = 20
        surf.module_manager.scalar_lut_manager.reverse_lut = True
        surf.module_manager.scalar_lut_manager.data_range = np.array([ 0.,  scale])
    
        return surf
    
    N = 500  # Grid points
    L = 2.5  # Box size
    X, Y = np.mgrid[-L:L:N*1j, -L:L:N*1j]
    scale = 2
    Z = step_function(N, scale, X, Y, shape="crescent")
    CFL = 0.125
    dx = X[1, 0] - X[0, 0]
    dy = dx
    dt = CFL*dx**2
    end_time = 0.05
    time = np.arange(0, end_time, dt)
    nframes = 50
    ntime = time.shape[0]
    ntime_anim = int(ntime/nframes)
    
    #%% Plot frames
    fname = "heat"
    bgcolor = (1, 1, 1)
    fig = mlab.figure(size=(1200, 1000), bgcolor=bgcolor)
    fig.scene.camera.azimuth(180)
    mlab.get_engine()
    engine = mlab.get_engine()
    scene = engine.scenes[0]
    for cont in range(nframes):
        mlab.clf()
        surf = data_gen(cont)
        scene.scene.camera.position = [-8, -8,  7]
        scene.scene.camera.clipping_range = [7, 22]
        scene.scene.camera.focal_point = [0, 0, 1]
        print(cont)
        mlab.savefig("{}_{n:02d}.png".format(fname, n=cont))
    
    #%% Generate video
    args = [path_to_convert, "-delay", "10", "-loop" , "0", fname + "_*.png",
            fname + ".gif"]
    subprocess.call(args, shell=True)
    subprocess.call(["del", "/Q", fname + "*.png"], shell=True)
    print("Done!")
    

    라이선스

    나는 아래 작품의 저작권자로서, 이 저작물을 다음과 같은 라이선스로 배포합니다:
    w:ko:크리에이티브 커먼즈
    저작자표시
    이 파일은 크리에이티브 커먼즈 저작자표시 4.0 국제 라이선스로 배포됩니다.
    이용자는 다음의 권리를 갖습니다:
    • 공유 및 이용 – 저작물의 복제, 배포, 전시, 공연 및 공중송신
    • 개작 – 저작물의 개작, 수정, 2차적저작물 창작
    다음과 같은 조건을 따라야 합니다:
    • 저작자표시 – 적절한 저작자 표시를 제공하고, 라이선스에 대한 링크를 제공하고, 변경사항이 있는지를 표시해야 합니다. 당신은 합리적인 방식으로 표시할 수 있지만, 어떤 방식으로든 사용권 허가자가 당신 또는 당신의 사용을 지지하는 방식으로 표시할 수 없습니다.

    설명

    이 파일이 나타내는 바에 대한 한 줄 설명을 추가합니다
    Animation of the heat equation with a crescent moon as initial condition.

    이 파일에 묘사된 항목

    다음을 묘사함

    2,787,307 바이트

    954 화소

    1,200 화소

    07900fef474dafbc79c213cb7fda9dbd859e8d06

    파일 역사

    날짜/시간 링크를 클릭하면 해당 시간의 파일을 볼 수 있습니다.

    날짜/시간섬네일크기사용자설명
    현재2017년 5월 20일 (토) 04:122017년 5월 20일 (토) 04:12 판의 섬네일1,200 × 954 (2.66 MB)wikimediacommons>NicoguaroUser created page with UploadWizard

    이 파일을 사용하는 문서가 없습니다.