Commit ae10accb by Pieter van Velde

### Added compuatation for end to end length for each polymer length in main.py and functions.py

parent d0ef7aa4
 import numpy as np import sys def add_bead(pos, n, T_dim, j, p_pol): def add_bead(pos, n, T_dim, j, p_pol, fails): """Adds one bead to polymer, according to the Rosenblaum method Parameters: ... ... @@ -25,7 +25,7 @@ def add_bead(pos, n, T_dim, j, p_pol): # Standard phi, KAN NAAR MAIN.PY phi_0 = np.linspace(0, 2 * np.pi - (2 / n) * np.pi, n) phi = phi_0 + (1 - 2 * np.random.rand(n)) * np.pi / n flag = 0 # Calculate new positions pos_new = np.zeros([n, 2]) pos_new[:, 0] = pos[j - 1, 0] + np.cos(phi) ... ... @@ -49,10 +49,11 @@ def add_bead(pos, n, T_dim, j, p_pol): w_tot = np.sum(w) # Stop execution if beads can only be placed (almost) on top of other beads if w_tot == 0: print('Help, I have nowhere to go') print('w_tot = ', w_tot) sys.exit() if w_tot < 1e-3: # BEETJE ME GEPIELD #print('Help, I have nowhere to go') #print('w_tot = ', w_tot) flag = 1 fails = fails + 1 # Calculate new position of next bead P = w / w_tot ... ... @@ -62,7 +63,11 @@ def add_bead(pos, n, T_dim, j, p_pol): # Calculate weights of one polymer to account for deviation from the theoretical value w_idx = np.where(phi == final_phi) w_jl = w[w_idx[0]] # print(w_jl) w_l = w_tot #print(w_tot) p_pol = p_pol * w_jl / w_l end_end = np.sqrt(pos[j, 0]**2 + pos[j,1]**2) return pos, p_pol \ No newline at end of file return pos, p_pol, flag, end_end, fails \ No newline at end of file