In [483]:
%matplotlib inline

In [484]:
import numpy as np

import bga_4_0 as bga
import manifold_reflected_brownian_motion as mrbm
import triangle_geometry as ti
import matplotlib.pyplot as plt
import polyhedra as poly
bga = reload(bga)
mrbm = reload(mrbm)

In [485]:
manifold_name = 'building_game'
#poly_name = 'tetrahedron'
poly_name = 'octahedron'
#poly_name = 'icosahedron'
int_num = 3

unary_boundary_name = 'self_intersection'
binary_boundary_name = 'dihedrals'

#stat_name = 'test_1'
#stat_name = 'test_2'
stat_name = 'bg_attachment'

In [486]:
manifold_kwargs = {'poly_name': poly_name, 
                   'int_num': int_num, 
                   'fixed_com': True,
                   'fixed_rotation': True}
#manifold_kwargs = {'poly_name': poly_name, 
#                   'int_num': int_num}
unary_boundary_kwargs = {'poly_name': poly_name, 'int_num': int_num}
binary_boundary_kwargs = {'poly_name': poly_name, 'int_num': int_num}
stat_kwargs = {'poly_name': poly_name, 'int_num': int_num}
#stat_kwargs = {}

In [487]:
err_tol = 10**-12
h = 0.05
N = 10**7

hist_min = 0.0
hist_max = 2.0*np.pi
hist_bins = 1000

In [488]:
kwargs = {'manifold_name': manifold_name,  
          'stat_name': stat_name,
          'manifold_kwargs': manifold_kwargs,
          'stat_kwargs': stat_kwargs,
          'record_hist': True, 
          'hist_min': hist_min, 
          'hist_max': hist_max, 
          'hist_bins': hist_bins,
          'err_tol': err_tol}

In [489]:
x0, links, lengths, faces = bga.load_bg_int(poly_name, int_num)

In [490]:
V, E, F, S, species, f_types, adj_list, dual = bga.get_poly(poly_name)
        
print faces
print adj_list


[[0, 3, 4], [1, 4, 3], [0, 4, 2]]
[[2, 3, 1], [4, 5, 0], [6, 0, 5], [0, 6, 4], [7, 1, 3], [1, 7, 2], [3, 2, 7], [5, 4, 6]]

In [491]:
z = mrbm.MRBM(x0, h, **kwargs)

In [492]:
z.sample(N=N)


____________________
--------------------
Out[492]:
array([-0.29977176, -0.11313679, -0.36378081, -0.37420097, -0.1488336 ,
       -0.32190473,  0.59884645,  0.27964088, -0.16830443,  0.24117103,
       -0.46471847,  0.40026842, -0.16604475,  0.44704798,  0.45372155])

In [502]:
z.write_histograms('hist_test.csv')

In [494]:
#x_A = np.array([0.5*3.0**0.5, 0.0, 0.0,
#                -0.5*3.0**0.5, 0.0, 0.0,
#                0.0, 0.5, 0.0,
#                0.0, -0.5, 0.0])
#x_B = np.array([0.25*3.0**0.5, 0.0, 0.0,
#                0.25*3.0**0.5, 0.0, 0.0,
#                -0.25*3.0**0.5, 0.5, 0.0,
#                -0.25*3.0**0.5, -0.5, 0.0])

In [495]:
#z_A = mrbm.MRBM(x_A, h, **kwargs)
#z_B = mrbm.MRBM(x_B, h, **kwargs)

In [496]:
#aaa = z_A.sample(N=N)
#print z_A.stat_log
#print z_A.stat_log[1,0] - z_A.stat_log[0,0]

In [497]:
#print z_A.stat_log

In [498]:
#bbb = z_B.sample()
#print z_B.stat_log
#print 2.0*np.pi + z_B.stat_log[1,0] - z_B.stat_log[0,0]

In [499]:
#N = 10**5
#z_A.sample(N=N)

In [500]:
#z_A.stat_log

In [501]:
#plt.plot(z_A.stat_log[1:-1,0], abs(z_A.stat_log[2:,0] - z_A.stat_log[:-2,0])/(2*h), '.')
#plt.ylim(0.0, 12.)
#plt.xlabel("Dihedral angle between triangles")
#plt.ylabel("Magnituge of rate of change of the Dihedral angle")
#plt.savefig("dihedral_change.png")