#def MakeTriangularSitePercolationVariant(L, p):
# g = Networks.UndirectedGraph()
# upNbrs = [[0,1],[1,0],[-1,1]]
# siteThere = scipy.random.random((L,L))
def PlotSitePercolation(L=10, p=0.5, seed=1, scale=0):
"""
Uses DrawTriangularNetworkSites to draw clusters.
"""
pass
#
def PlotSitePercolationBiggest(L=10, p=0.5, seed=1, scale=0):
"""
Uses DrawTriangularNetworkSites to draw only the largest cluster,
by setting cl to the result of Networks.FindAllClusters (presuming
it sorts by size) and by passing in [cl[0]] as the cluster list.
"""
pass
#
# ***** More advanced exercise: knowledge of scaling and ***** #
# ***** renormalization group useful ***** #
# ***** Read "PercolationScaling.pdf") from Percolation.html. ***** #
#
def PlotLogLogSizeDistributionHist(L=100, p=0.5, log10binsize=0.25,
min=1.e-10, repeats=1):
"""
Make bond percolation graph
Find clusters
Make list of sizes of all the clusters
Make two dictionaries, S and D for the different size and probability
curves. (The dictionary keys are used by MultiPlot as curve labels).
Make two lists, S['bond'] = [0,1,2,...] and D['bond']=[D(0), D(1), ...],
where D(S) is the number of clusters of size S
pylab.plot(S['bond'],D['bond']), then pylab.show()
should generate a plot of D(S)
If you ensure that D(S) > 0 for all points (say, by adding min=1.e-10 to
all the entries), you can do
pylab.loglog(S['bond'],D['bond'])
to do a log-log plot
#
Make two more lists, S['site'] and D['site'] for site percolation
#
You can now either change colors by hand
("bo" for blue circles with lines, "ro" for red, ...),
pylab.plot(S['bond'],D['bond'], "bo-")
pylab.plot(S['site'],D['site'], "ro-")
pylab.show()
or you can use our package
MultiPlot.MultiPlot(S, D, xlabel='S', ylabel='D(S)')
which should give legends and axis labels.
Do help(MultiPlot.MultiPlot) for more details, for log-log plots, etc.
#
Add the theory curve using the cool property that one
can take powers of scipy arrays:
D['power'] = S['power']**(-tau)!
#
You'll find that the data curves become unreliable as soon as there
are sizes with only a few clusters. We can cure this by binning
several sizes in one bin. The bookkeeping for doing this is a bit
messy, so we provide a package, IntegerHistogram.
(1) Take your data points (sizes, all integers)
make a long list of them called "sizes"
(2) Set up the bins you like. I recommend
bins =10.**arange(0.0,log10(L*L),0.25)
(3) S['bond'], D['bond'] = IntegerHistogram.IntegerHistogram(sizes, bins)
will give the centers and average counts per integer for each bin
"""
pass
#
def PlotLogLogBeta(L=10, pc=0.5, n=10, repeats=1):
pass
#
def PlotPofp(Ls = [5, 10, 20], repeats=1):
"""Here, because you'll want to study small systems as well as large
ones, you'll need to average over several realizations of the
disorder.
(1) Remember that the variance of the mean is 1/(repeats-1) times
the variance of the sample, so the standard deviation
is sqrt(<(P-Pbar)^2>/(repeats-1)) =
sqrt((P2Sum - PSum**2/repeats)/(repeats*(repeats-1))
(2) A good range of p might be 2.5/L on each side of pc?
Generate the array of p values using scipy.arange.
(3) To use MultiPlot.
(a) Make dictionaries pValues[L, type], Pbar[L, type], and sigma[L, type]
where type = 'site' or 'bond'
(b) Plotting the (unrescaled) curves can be done with
MultiPlot.MultiPlot(pValues, Pbar,
xform='p->p', yform='P->P',
yerrdata=sigma, yerrform = 'sigma->sigma',
loc='upper left',
showIt=True)
(c) Doing your scaling collapses, you'll need to add
keyNames=('L',"type") and a scalingParams dictionary to Multiplot's
argument list."""
pass
#
# -----------------------------------------------------------------------
#
# For percolation on a protein interaction network
#
# -----------------------------------------------------------------------
#
def RandomPrune(graph, delta):
pass
#
def Percolate(graph, deltas):
pass
#
def MultiPercolate(graph, deltas, numruns):
pass
#
def TestMultiPercolate():
pass
#
# Copyright (C) Cornell University
# All rights reserved.
# Apache License, Version 2.0