Skip to content

Instantly share code, notes, and snippets.

View stefanocampanella's full-sized avatar

Stefano Campanella stefanocampanella

  • National Institute of Oceanography and Applied Geophysics - OGS
  • Trieste, Italy
View GitHub Profile
using StaticArrays
s1(n) = floor(Int, 0.25 * (1+3/√5)/(-2+√5)^(n+1))
function s2(n)
M = [1. 2.; 2. 3.]
v = [1.; 1.]
s = v' * inv(M - eye(2,2)) * (M^(n+1) - eye(2,2)) * v
round(Int, s)
end
import math as m
import matplotlib.pyplot as plt
import numpy as np
import numpy.fft as dft
import numpy.linalg as lin
import numpy.random as rnd
# Parameters
L = 1.0
#include <iostream>
#include <fstream>
#include <cmath>
#include <random>
#include <array>
#include <iterator>
#include <memory>
#include <omp.h>
typedef std::mt19937_64 rng_t;
import System.Random
import Data.List
t0 = 0.0 :: Double
x0 = 0.0 :: Double
v0 = 0.0 :: Double
dt = 0.005 :: Double
beta = 1.0 :: Double
alpha = 1.0 :: Double
# The bulk is made of Ar, the gas which thermalize is He.
# units are (10^-27 Kg, 10^-10 m, 10^-9 s).
using ProgressMeter
using GR
# Costants
const Kb = 1.3806e6
# Simulation parameters
const t_stop = 5.0
% !TEX TS-program = lualatex
\batchmode
\documentclass[a4paper,oneside,12pt]{article}
\usepackage[margin=1in]{geometry}
\usepackage{fontspec}
\setmainfont{Courier Std}
\usepackage{microtype}
\usepackage[english]{babel}
\usepackage{setspace}
#! /usr/bin/python
from sys import argv
from pyx.canvas import canvas
from pyx.path import moveto, path, rlineto
from pyx.style import linewidth as lw
iterations = int(argv[1])
outfile = argv[2]
u = 0.5
encode[s_] := Module[{n,ascii,pi,code,str,frm`str},
n=StringLength[s];
ascii=Flatten@IntegerDigits[ToCharacterCode[s,"ASCII"],2,7];
pi=First@RealDigits[\[Pi],10,7(n+2)];
code=Join[Take[pi,7],Mod[ascii+Take[pi,{8,-8}],10],Take[pi,-7]];
str = StringJoin@Map[ToString,code];
frm`str = InsertLinebreaks[StringInsert[str," ",Range[8,7(n+2),7]],7*9];
Return [frm`str]]
decode[s_] := Module[{frm`str,code,pi,ascii,str},
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
using ProgressMeter
using Images
transition_probabilities(T) = collect(0.5(1+tanh(-i/T)) for i = 1:4)
@inline function metropolis!(s,p)
N, M = size(s)
for j = 1:M, i = 1:N
@inbounds ds = s[i,j] * ( s[i == 1 ? N : i-1, j] + s[i == N ? 1 : i+1, j] +
s[i, j == 1 ? M : j-1] + s[i, j == M ? 1 : j+1] )