Commit 06cc6eb4 authored by Luuk Balkenende's avatar Luuk Balkenende

Moved non-global variables to functions

parent 0ace1a1f
This diff is collapsed.
......@@ -2,10 +2,10 @@
import numpy as np
from matplotlib import pyplot as plt
import random
from functions import add_bead, limits, prune, enrich, maxsize, stack_init, exp_calc
from functions import calc_pol, allocate, init, perm, add_bead, limits, prune, enrich, maxsize, stack_init, exp_calc
# Simulation parameters
n_beads = 250 # number of beads
n_beads = 100 # number of beads
n = 6 # number of angles
n_pol = 10 # number of polymers
alfa_up = 2 # alfa to compute upper limit
......@@ -15,56 +15,11 @@ cst_dep = 1 / (0.75 * n) # multiplication constant for L dependence perm
# Physical parameters
T_dim = 10 # T * (Kb / eps) # Non-dimensional temperature
pos_stack, polweight_stack, end_end_stack, pos_array, polweight_array, end_end_array = stack_init(n_beads, n_pol)
# Calculate configuration of polymers and their weights
end_end_array, polweight_array = calc_pol(n_beads, n, n_pol, alfa_low, alfa_up, cst_dep, T_dim)
enrich1 = 0
prune1 = 0
flag = 1
fails = 0
j = 2
m = 0
while flag == 1:
k = 0
while k < polweight_stack.shape[1]:
pos_stack[:, 2 * k:2 * k + 2], polweight_stack[j, k], end_end_stack[j, k], fails = add_bead(
pos_stack[:, 2 * k:2 * k + 2], n, T_dim, polweight_stack[j - 1, k], fails, cst_dep, j)
uplim, lowlim = limits(polweight_stack, alfa_up, k, alfa_low, j)
if polweight_stack[j, k] < lowlim:
prune1 = prune1+1#(prune1 + 1) / 2
pos_stack, polweight_stack, pos_array, polweight_array, end_end_stack, end_end_array, k, m = prune(
polweight_stack, pos_stack, pos_array, polweight_array, end_end_stack, end_end_array, k, m)
elif polweight_stack[j, k] > uplim:
enrich1 = enrich1 + 1
polweight_stack, pos_stack, end_end_stack, k = enrich(polweight_stack, pos_stack, end_end_stack, k)
k = k + 1
if pos_stack.size == 0 or j == n_beads - 1:
flag = 0
print('stack equal to zero at number of beads = ', j)
j = j + 1
print(j)
end_end_array = np.c_[end_end_array, end_end_stack]
polweight_array = np.c_[polweight_array, polweight_stack]
exp_value = exp_calc(polweight_array, end_end_array)
a = np.arange(2, n_beads - 1, 1)
# if np.count_nonzero(end_end_stack) != 0:
# print('sukkel')
# #print('end', end_end_stack)
# exp_value = exp_calc(polweight_stack, end_end_stack)
# a = np.arange(2, n_beads - 1, 1)
# print(np.count_nonzero(end_end_array))
# if np.count_nonzero(end_end_array) != 0:
# print('wiehoee')
# times_weight = np.multiply(end_end_array, polweight_array)
#
# print('times_weight = ', times_weight)
plt.figure()
plt.loglog(a, exp_value[2:n_beads - 1] ** 2, marker="x", markersize=7, color="k")
......@@ -73,7 +28,4 @@ plt.xlabel('N (Number of beads)')
plt.grid(True, which="both", ls="-")
plt.ylim(1, 10000)
plt.xlim(1, 250)
print(polweight_stack.shape)
print('enrich = ', enrich1)
print('prune = ', prune1/2)
plt.show()
plt.show()
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment