Skip to content

Commit 7762450

Browse files
committed
preparing to run simulation with linear modulation of twist persistance length
1 parent 3125803 commit 7762450

20 files changed

Lines changed: 23 additions & 4328 deletions

chromo/mc/__init__.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,6 @@ def _polymer_in_field(
5151
path_to_run_script: Optional[str] = None,
5252
path_to_chem_mods: Optional[List[str]] = None,
5353
run_command: Optional[str] = None,
54-
#lt_value_adjust = 1,
5554
**kwargs
5655
):
5756
"""
@@ -142,27 +141,29 @@ def _polymer_in_field(
142141
temperature_adjust_factor = temp_schedule.logarithmic_decrease(mc_count, num_saves)
143142
elif temperature_schedule == "decreasing stepwise":
144143
temperature_adjust_factor = temp_schedule.decreasing_stepwise(mc_count, num_saves)
144+
elif temperature_schedule == "no schedule":
145+
temperature_adjust_factor = temp_schedule.no_schedule()
145146
else:
146147
print("Not a valid temperature schedule option")
147148
else:
148-
temperature_adjust_factor = 1
149+
print("Missing lt schedule option")
149150

150151
if lt_schedule is not None:
151152
if lt_schedule == "logarithmic increase":
152-
#print(mc_count)
153-
#print(num_saves)
154153
lt_change = twist_schedule.logarithmic_increase(mc_count, num_saves)
155154
elif lt_schedule == "linear increase":
156155
lt_change = twist_schedule.linear_increase(mc_count, num_saves)
157156
elif lt_schedule == "increasing stepwise":
158157
lt_change = twist_schedule.increasing_stepwise(mc_count, num_saves)
158+
elif lt_schedule == "no schedule":
159+
lt_change = twist_schedule.no_schedule()
159160
else:
160161
print("Not a valid lt schedule option")
161162
else:
162-
lt_change = 1
163+
print("Missing lt schedule option")
163164
#print("lt change " + str(lt_change))
164165

165-
temperature_adjust_factor=1
166+
temperature_adjust_factor = 1
166167
lt_value_adjust= lt_change
167168

168169
decorator_timed_path(output_dir)(mc_sim)(

chromo/mc/mc_sim.pyx

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ cpdef void mc_sim(
3333
list mc_move_controllers, Udf field, double mu_adjust_factor,
3434
long random_seed, double temperature_adjust_factor, double lt_value_adjust
3535
):
36-
print('Hi')
3736
"""Perform Monte Carlo simulation.
3837
3938
Pseudocode
@@ -88,24 +87,15 @@ cpdef void mc_sim(
8887
if controller.move.move_on == 1:
8988
for j in range(controller.move.num_per_cycle):
9089
for i in range(len(polymers)):
91-
#print("start lt")
92-
#print(polymers[i].lt)
9390
polymers[i].lt = lt_value_adjust
94-
polymers[i]._find_parameters(polymers[i].bead_length)
91+
polymers[i]._find_parameters(polymers[i].bead_length) # coding best practice: accessing protected member of a class from outside the class?
9592
poly = polymers[i]
96-
97-
#print("lt change factor")
98-
#print(lt_value_adjust)
99-
#print("new lt value " + str(polymers[i].lt ))
100-
101-
10293
active_field = active_fields[i]
10394
mc_step(
10495
controller.move, poly, readerproteins, field,
10596
active_field, temperature_adjust_factor
10697
)
10798
controller.update_amplitudes()
108-
#print(poly.lt)
10999

110100

111101
cpdef void mc_step(
@@ -136,6 +126,8 @@ cpdef void mc_step(
136126
Field affecting polymer in Monte Carlo step
137127
active_field: bool
138128
Indicator of whether or not the field is active for the polymer
129+
temperature_adjust_factor: double
130+
Divide the energy value used to select accepted moves by this factor
139131
"""
140132
cdef double dE, exp_dE
141133
cdef int check_field = 0

chromo/run_simulation.py

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
from chromo.util.reproducibility import get_unique_subfolder_name
2626
import chromo.util.poly_stat as ps
2727
import datetime
28-
import chromo.util.temperature_schedule as temperature
28+
2929

3030
pst_time = datetime.datetime.utcnow() + datetime.timedelta(hours=-7)
3131

@@ -65,7 +65,6 @@
6565
lp=lp,
6666
lt=lt,
6767
binder_names=np.array(["null_reader"]),
68-
#lt_schedule = "logarithmic increase"
6968
)
7069

7170
# shows a plot of the polymer object
@@ -117,6 +116,9 @@
117116
# count number of accepted moves for different conditions
118117
mc_steps_per_snapshot = 40000
119118

119+
120+
121+
120122
mc.polymer_in_field(
121123
polymers = [polymer],
122124
binders = binders,
@@ -127,16 +129,10 @@
127129
move_amp_bounds = amp_move_bounds,
128130
output_dir = 'output',
129131
mc_move_controllers = moves_to_use,
130-
temperature_schedule = "linear decrease",
132+
temperature_schedule = "no schedule",
131133
lt_schedule = "linear increase"
132134
)
133135

134-
135-
#temperature_schedule: Optional[Callable[[float],float]] = None
136-
# Load names of polymer configuration output files
137-
# 206 is with 200 snapshots of twist with alternating 15 and 25
138-
# 130 is without twist with alternating 15 and 25
139-
#latest_sim = "output/sim_206"
140136
output_files = os.listdir(latest_sim)
141137

142138
output_files = [
@@ -226,10 +222,9 @@
226222
if monomer_separation[i] > 0
227223
]
228224
)
229-
# monomer_separation_kuhn = monomer_separation * (bead_spacing / lp / 2)
225+
230226
monomer_separation_kuhn = monomer_separation * (np.mean(bead_spacing) / lp / 2) # check that this is acceptable
231-
# do calc with same bead spacing
232-
#
227+
233228

234229
lp = 100 # try 53
235230
kuhn_length = 2 * lp

chromo/twist_schedule.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
12
class Schedule:
23
"""Class representation of the simulated annealing schedule.
34
@@ -27,4 +28,6 @@ def logarithmic_increase(current_step, total_steps):
2728

2829
def linear_increase(current_step, total_steps):
2930
value = (current_step/total_steps) * 100
30-
return value
31+
return value
32+
def no_schedule():
33+
return 100

chromo/util/temperature_schedule.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,4 +32,6 @@ def linear_decrease(current_step, total_steps):
3232
slope = (0.1 - 1) / total_steps
3333
value = 1 + slope * current_step
3434
return value
35+
def no_schedule():
36+
return 1
3537

slurm-26773980.out

Lines changed: 0 additions & 9 deletions
This file was deleted.

slurm-26776755.out

Lines changed: 0 additions & 4 deletions
This file was deleted.

slurm-27088587.out

Lines changed: 0 additions & 4 deletions
This file was deleted.

slurm-29005217.out

Lines changed: 0 additions & 7 deletions
This file was deleted.

0 commit comments

Comments
 (0)