Exemplo n.º 1
0
def critK(d, farey, wantPlot=False):
    kGuess = -math.log(1 / (2 * d) - 1) / math.log(2)  # if 0, 1/2 overlap
    step = 1.0
    while True:
        if max(getP(d, kGuess, farey)[1]) == 0:
            kGuess = kGuess + step
        else:
            if step < 1e-5:
                break
            else:
                kGuess = kGuess - step
                step = step / 10.0
    if wantPlot:
        xK, pK, gradpK = getP(d, kGuess + step, farey)
        plot(xK, gradpK, label="A little pressure", linewidth=2)
        xM, pM, gradpM = getP(d, kGuess - step, farey)
        plot(xM, gradpM, "r", label="No Pressure")
        ylim((-0.1, 1.1))
        legend()
        show()
    x, p, gradp = getP(d, kGuess + step, farey)
    return kGuess, (x[3] + x[2]) / 2  # last irrational < 0.5
Exemplo n.º 2
0
from pylab import *
import numpy as np
from fractal import getP #(d, k, nmax), returns x, p, gradp
from scipy.interpolate import interp1d

x, p, gradp = getP(0.1, 2, 200)

def getLength(x,p,r):
    newX = np.arange(0,1,0.0001)
    newP = interp1d(x,p)
    xs, ys = [x[0]], [p[0]]
    theta = np.arange(0,np.pi/2.,0.001)
    length = 0
    while xs[-1] + r < 1:
        xNow = xs[-1] + r*np.cos(theta)
        yNow = ys[-1] + r*np.sin(theta)
        pNow = newP(xNow)
        match = np.argwhere(np.isclose(yNow,pNow, atol=0.0005))
        match = round(np.mean(match))
        xs.append(xNow[match])
        ys.append(yNow[match])
        length += r
    
    remaining = sqrt((xs[-1]-1)**2+(ys[-1]-p[-1])**2)
    length += remaining
        
    return length
        
lengths = []
rs = [1,.1, .01, .001, .0001, 1e-5]
for r in rs:
Exemplo n.º 3
0
from pylab import *
import numpy as np
from fractal import getP

nmax = 100
drange = np.arange(0,.51,0.005)
krange = np.arange(1, 4.02,0.01)
lenD, lenK = len(drange), len(krange)

storeP = np.zeros((lenD,lenK,nmax))
clf()
cmap = get_cmap('RdBu')
cmap.set_under('black')
cmap.set_over('green')

for n in range(1,nmax):
    for d in range(lenD):
        for k in range(lenK):
            storeP[d,k,n-1] = max(getP(drange[d],krange[k],n)[1])
            
    pcolor(krange,drange,storeP[:,:,n-1],cmap=cmap,vmin=0.001,vmax=.999)
    title('Max pressure at Farey level '+str(n))
    colorbar(extend='both')
    ylim(0,.5)
    xlim(1,4)
    savefig('C:/Users/bkraus/Dropbox/Hudson/Images_dkMaps_020516/dk'+str(n)+'.jpg')
    clf()