1. install it using

    #pkg install gnome3

    /etc/fstab 

    proc           /proc       procfs  rw  0   0

    /etc/rc.conf

    gdm_enable=“YES”
    gnome_enable="YES"

    The menu is missing

    install Parallel Tools

    #cd /usr/ports/emulators/parallels-tools/ && make install clean

    but it need kernel source. 

    Install via svn

    #pkg install devel/subversion

    # svnlite checkout http://svn0.eu.freebsd.org/base/releng/10.0/ /usr/src

    run it again

    #cd /usr/ports/emulators/parallels-tools/ && make install clean











    0

    Add a comment


  2. Got boot-only iso and managed to install it on my Parallel Desktop on my Macbook Air with Yosemite. 

    Of course it just CLI.

    Strange, the root shell have tab completion feature, but the normal users didn’t.

    (DuckDuckGo-ing)

    The answer come from 2003 and 2005 Mailing-List, :)

    To enable tab completion
     
    $chsh -s /bin/tcsh
    
    
     
    (it didn’t enable tab completion actually , it change shell with tab completion feature :) )
    We could so use
     
    
    
    $chsh -s /bin/csh 
    
    
     
    tcsh shell support tab completion too.
    
    
     
    Another thing is, normal user can’t use sudo command (because it’s not installed, :P )
    So,  install sudo first (I used pkg command instead of pkg_add)
    
    
     
    #pkg install sudo 
     
     
    edit /usr/local/etc/sudoers as root and visudo command (don’t edit it using regular vi editor, or ANY editor)
    
    
    %visudo
    
    
    add this
    
    
    username ALL=(ALL) ALL
    
    
     
    and life become more easier...
    
    
    
    
     
     
    
    
    0

    Add a comment


  3. based on Solarian Programmer

    Download and install in order: 

    gmp-6.0.0 
    mpfr-3.1.2 
    mpc-1.0.2 

    isl-0.12.2 
    cloog-0.18.1 

    and finally 
    gcc-4.9.2  

    note: make sure the version of each library is exactly as above, I downloaded cloog-0.18.2 and it failed to install [got …"No such file or directory” error message], so I revert to cloog-0.18.1  (don’t know the reason behind it, but at least it worked, :)  )




    The Desktop

    0

    Add a comment

  4. This code print d and e as result of two matrix addition, e's using python native code, d's using fortran module compiled with F2PY

    The code
    import numpy as np
    import aravir as ar
    import time
    
    n = 1000
    
    u = np.ones((n,n))
    v = np.ones((n,n))
    e = np.ones((n,n))
    
    t = time.clock()
    d = ar.add3(u,v)
    tfortran= time.clock()-t
    
    t = time.clock()
    for i in range (n):
        for j in range (n):
            e[i,j] = u[i,j]+v[i,j]
    tnative = time.clock()-t
    
    print 'fortran ', d
    print 'native', e
    print 'tfortran = ', tfortran, ', tnative = ', tnative
    


    The fortran module I imported to python
            subroutine add3(a, b, c, n)
            double precision a(n,n)
            double precision b(n,n)
            double precision c(n,n)
    
            integer n
    cf2py   intent(in) :: a,b
    cf2py   intent(out) :: c,d
    cf2py   intent(hide) :: n
            do 1700 i=1, n
                do 1600 j=1, n
                    c(i,j) = a(i,j)
         $              +b(i,j)
    
    1600         continue
    1700     continue
            end
    

    save it as aravir.f and compile using
    $ f2py -c aravir.f -m aravir
    

    And here the result
    $ python cobamodul.py 
    fortran  [[ 2.  2.  2. ...,  2.  2.  2.]
     [ 2.  2.  2. ...,  2.  2.  2.]
     [ 2.  2.  2. ...,  2.  2.  2.]
     ..., 
     [ 2.  2.  2. ...,  2.  2.  2.]
     [ 2.  2.  2. ...,  2.  2.  2.]
     [ 2.  2.  2. ...,  2.  2.  2.]]
    native [[ 2.  2.  2. ...,  2.  2.  2.]
     [ 2.  2.  2. ...,  2.  2.  2.]
     [ 2.  2.  2. ...,  2.  2.  2.]
     ..., 
     [ 2.  2.  2. ...,  2.  2.  2.]
     [ 2.  2.  2. ...,  2.  2.  2.]
     [ 2.  2.  2. ...,  2.  2.  2.]]
    tfortran =  0.069974 , tnative =  1.202547
    

    The Desktop, :)


    0

    Add a comment

  5. Python is easy to use, but it's slow, especially for loop computation. So I compute it using fortran like this

            subroutine subs(a, b, n)
            double precision a(n)
            double precision b(n)
            integer n
    cf2py   intent(in) :: a
    cf2py   intent(out) :: b
    cf2py   intent(hide) :: n
    !        b(1) = a(1)
            do 100 i=2, n
                    b(i) = a(i)-1
    100     continue
            end
    
    

    save it as aravir.py and do the following command
    $ f2py -c aravir.f -m aravir
    

    To use the module on the python I use the code below
    import numpy as np
    import aravir as ar
    
    a = np.linspace(0,1,100)
    
    b = ar.subs(a)
    
    print a
    print b
    

    :)


    0

    Add a comment

  6. I used Numpy  Matplotlib with Animation and 3d Plot module on my OS X Yosemite.

    The code is still messy and clearly not efficient (there's slow loop here and there) but it works, :)
    Here The Result
    The Code
    import numpy as np
    
    n = 8;
    g = 9.8;
    dt = 0.02;
    dx = 1.0;
    dy = 1.0;
    
    h = np.ones((n+2,n+2))
    u = np.zeros((n+2,n+2))
    v = np.zeros((n+2,n+2))
    
    hx = np.zeros((n+1,n+1))
    ux = np.zeros((n+1,n+1))
    vx = np.zeros((n+1,n+1))
    
    hy = np.zeros((n+1,n+1))
    uy = np.zeros((n+1,n+1))
    vy = np.zeros((n+1,n+1))
    
    nsteps = 0
    h[1,1] = .5;
    
    def reflective():
        h[:,0] = h[:,1]
        h[:,n+1] = h[:,n]
        h[0,:] = h[1,:]
        h[n+1,:] = h[n,:]
        u[:,0] = u[:,1]
        u[:,n+1] = u[:,n]
        u[0,:] = -u[1,:]
        u[n+1,:] = -u[n,:]
        v[:,0] = -v[:,1]
        v[:,n+1] = -v[:,n]
        v[0,:] = v[1,:]
        v[n+1,:] = v[n,:]
    
    def proses():
        #hx = (h[1:,:]+h[:-1,:])/2-dt/(2*dx)*(u[1:,:]-u[:-1,:])
        for i in range (n+1):
            for j in range(n):
                hx[i,j] = (h[i+1,j+1]+h[i,j+1])/2 - dt/(2*dx)*(u[i+1,j+1]-u[i,j+1])
                ux[i,j] = (u[i+1,j+1]+u[i,j+1])/2- dt/(2*dx)*((pow(u[i+1,j+1],2)/h[i+1,j+1]+ g/2*pow(h[i+1,j+1],2))- (pow(u[i,j+1],2)/h[i,j+1]+ g/2*pow(h[i,j+1],2)))
                vx[i,j] = (v[i+1,j+1]+v[i,j+1])/2 - dt/(2*dx)*((u[i+1,j+1]*v[i+1,j+1]/h[i+1,j+1]) - (u[i,j+1]*v[i,j+1]/h[i,j+1]))
    
        for i in range (n):
            for j in range(n+1):
                hy[i,j] = (h[i+1,j+1]+h[i+1,j])/2 - dt/(2*dy)*(v[i+1,j+1]-v[i+1,j])
                uy[i,j] = (u[i+1,j+1]+u[i+1,j])/2 - dt/(2*dy)*((v[i+1,j+1]*u[i+1,j+1]/h[i+1,j+1]) - (v[i+1,j]*u[i+1,j]/h[i+1,j]))
                vy[i,j] = (v[i+1,j+1]+v[i+1,j])/2 - dt/(2*dy)*((pow(v[i+1,j+1],2)/h[i+1,j+1] + g/2*pow(h[i+1,j+1],2)) - (pow(v[i+1,j],2)/h[i+1,j] + g/2*pow(h[i+1,j],2)))
        
        for i in range (1,n+1):
            for j in range(1,n+1):
                h[i,j] = h[i,j] - (dt/dx)*(ux[i,j-1]-ux[i-1,j-1]) - (dt/dy)*(vy[i-1,j]-vy[i-1,j-1])
                u[i,j] = u[i,j] - (dt/dx)*((pow(ux[i,j-1],2)/hx[i,j-1] + g/2*pow(hx[i,j-1],2)) - (pow(ux[i-1,j-1],2)/hx[i-1,j-1] + g/2*pow(hx[i-1,j-1],2))) - (dt/dy)*((vy[i-1,j]*uy[i-1,j]/hy[i-1,j]) - (vy[i-1,j-1]*uy[i-1,j-1]/hy[i-1,j-1]))
                v[i,j] = v[i,j] - (dt/dx)*((ux[i,j-1]*vx[i,j-1]/hx[i,j-1]) - (ux[i-1,j-1]*vx[i-1,j-1]/hx[i-1,j-1])) - (dt/dy)*((pow(vy[i-1,j],2)/hy[i-1,j] + g/2*pow(hy[i-1,j],2)) - (pow(vy[i-1,j-1],2)/hy[i-1,j-1] + g/2*pow(hy[i-1,j-1],2)))
    
    #dh = dt/dt*(ux[1:,:]-ux[:-1,:])+ dt/dy*(vy[:,1:]-vy[:,:-1])
        reflective()
        return h,u,v
    '''
    for i in range (17):
        #print h
        proses(1)
    '''
    
    import matplotlib.pyplot as plt
    from matplotlib import cm
    from matplotlib.ticker import LinearLocator, FormatStrFormatter
    from mpl_toolkits.mplot3d import Axes3D
    a = n
    x = np.arange(n+2)
    y = np.arange(n+2)
    x,y = np.meshgrid(x,y)
    
    fig = plt.figure()
    
    ax = fig.add_subplot(111, projection='3d')
    
    def plotset():
        ax.set_xlim3d(0, a)
        ax.set_ylim3d(0, a)
        ax.set_zlim3d(0.5,1.5)
        ax.set_autoscalez_on(False)
        ax.zaxis.set_major_locator(LinearLocator(10))
        ax.zaxis.set_major_formatter(FormatStrFormatter('%.02f'))
        cset = ax.contour(x, y, h, zdir='x', offset=0 , cmap=cm.coolwarm)
        cset = ax.contour(x, y, h, zdir='y', offset=n , cmap=cm.coolwarm)
        cset = ax.contour(x, y, h, zdir='z', offset=.5, cmap=cm.coolwarm)
    
    plotset()
    
    surf = ax.plot_surface(x, y, h,rstride=1, cstride=1,cmap=cm.coolwarm,linewidth=0,antialiased=False, alpha=0.7)
    
    fig.colorbar(surf, shrink=0.5, aspect=5)
    
    
    from matplotlib import animation
    
    
    def data(k,h,surf):
        proses()
        ax.clear()
        plotset()
        surf = ax.plot_surface(x, y, h,rstride=1, cstride=1,cmap=cm.coolwarm,linewidth=0,antialiased=False, alpha=0.7)
        return surf,
    
    ani = animation.FuncAnimation(fig, data, fargs=(h,surf), interval=10, blit=False)
    #ani.save('air.mp4', bitrate=512)
    plt.show()
    

    and the snapshot






    0

    Add a comment

  7. And here's the animation
    import numpy as np
    import matplotlib.pyplot as plt
    import matplotlib.animation as animation
    from mpl_toolkits.mplot3d import Axes3D
    
    def data(i, z, line):
        z = np.sin(x+y+i)
        ax.clear()
        line = ax.plot_surface(x, y, z,color= 'b')
        return line,
    
    n = 2.*np.pi
    fig = plt.figure()
    ax = fig.add_subplot(111, projection='3d')
    
    x = np.linspace(0,n,100)
    y = np.linspace(0,n,100)
    x,y = np.meshgrid(x,y)
    z = np.sin(x+y)
    line = ax.plot_surface(x, y, z,color= 'b')
    
    ani = animation.FuncAnimation(fig, data, fargs=(z, line), interval=30, blit=False)
    
    plt.show()
    

    The result

    The snapshot



    0

    Add a comment

  8. It's slightly modified from before

    import numpy as np
    import matplotlib.pyplot as plt
    import matplotlib.animation as animation
    from mpl_toolkits.mplot3d import Axes3D
    
    n = 2.*np.pi
    fig = plt.figure()
    ax = fig.add_subplot(111, projection='3d')
    
    x = np.linspace(0,n,100)
    y = np.linspace(0,n,100)
    x,y = np.meshgrid(x,y)
    z = np.sin(x+y)
    line = ax.plot_surface(x, y, z,color= 'b')
    
    plt.show()
    


    the result


    the snapshot



    0

    Add a comment

  9. Here is the update from before

    import numpy as np
    import matplotlib.pyplot as plt
    import matplotlib.animation as animation
    
    def simData():
        t_max = n
        dt = 1./8
        k = 0.0
        t = np.linspace(0,t_max,100)
        while k < t_max:
            x = np.sin(np.pi*t+np.pi*k)
            k = k + dt
            yield x, t
    
    def simPoints(simData):
        x, t = simData[0], simData[1]
        line.set_data(t, x)
        return line
    n = 2.
    fig = plt.figure()
    ax = fig.add_subplot(111)
    line, = ax.plot([], [], 'b')
    ax.set_ylim(-1, 1)
    ax.set_xlim(0, n)
    
    ani = animation.FuncAnimation(fig, simPoints, simData, blit=False,\
                                  interval=100, repeat=True)
    plt.show()
    

    and the result
    0

    Add a comment

  10. Coding like this

    import numpy as np
    from matplotlib import pyplot as plt
    from matplotlib import animation
    
    fig = plt.figure()
    n = 10
    x = np.linspace(0,2*np.pi,100)
    
    
    
    def init():
        pass
    def animate(k):
        h = np.sin(x+np.pik)
        plt.plot(x,h)
    
    
    ax = plt.axes(xlim=(0, 2*np.pi), ylim=(-1.1, 1.1))
    
    anim = animation.FuncAnimation(fig, animate,init_func=init,frames=360,interval=20,blit=False)
    
    plt.show()
    

    The result
    0

    Add a comment

Archive
Label
Popular Posts
Popular Posts
Loading