Skip to content

Instantly share code, notes, and snippets.

View prcastro's full-sized avatar

Paulo Roberto de Oliveira Castro prcastro

View GitHub Profile
@prcastro
prcastro / hb_diagram.jl
Last active August 29, 2015 14:03
hb_diagram for Ising Module
# Phase diagram (magnetization by temperature) using heat bath algorithm
function hb_diagram(;n::Int=20, m::Int=50, max::Float64=6.0, h::Float64 = 0.0, iters::Int=50000, ε::Float64 = 0.001, plot::Bool=true, verbose::Bool=true)
temps = Array(Float64, n)
mags = Array(Float64, n)
i = 1
for temp in linspace(0.5, max, n)
avgmag = mean([heatbath!(spinarray(n), h=h, temp=temp, iters=iters, ε=ε, plot=false, verbose=false)[end] for i in 1:m])
if verbose println("(T=$temp) Avg. magnetization after heat bath $avgmag") end
temps[i] = t
mags[i] = avgmag
@prcastro
prcastro / newton.jl
Created August 26, 2014 22:51
Newton Method
function newton(f::Function, df::Function, x::Real, precision::Float64 = 10.0^(-6)/5.00)
x_prox = x - f(x)/df(x)
i = 1
while abs(x_prox - x) >= precision
x = x_prox
x_prox = x - f(x)/df(x)
i += 1
end
println("Numero de iterações: ", i)
from pdfminer.pdfparser import PDFParser
from pdfminer.pdfdocument import PDFDocument
from pdfminer.pdfpage import PDFPage
from pdfminer.pdfpage import PDFTextExtractionNotAllowed
from pdfminer.pdfinterp import PDFResourceManager
from pdfminer.pdfinterp import PDFPageInterpreter
from pdfminer.pdfdevice import PDFDevice
from pdfminer.layout import LAParams
from pdfminer.converter import PDFPageAggregator
import pdfminer