def trackAlpha_vsNc(x_Nc): date = strftime("%Y_%m_%d_%H_%M") filename = date + '_trackAlphaAfterDSB_vsNc' with open('results/' + filename + '.csv', 'w') as csvfile: first_time = True for i, Nc in enumerate(x_Nc): polymerParams['Nc'] = Nc p0 = RCLPolymer(**polymerParams) # Waiting time will be relaxation time (Nc dependant) simulationParams['waitingSteps'] = np.ceil( p0.relaxTime(simulationParams['diffusionConstant']) / simulationParams['dt_relax']).astype(int) simulationParams['VE_waitingSteps'] = np.ceil( p0.relaxTime(simulationParams['diffusionConstant']) / simulationParams['dt']).astype(int) results = {**polymerParams, **simulationParams} mc = Experiment(p0, results, simulationParams, trackAlpha) if first_time: fieldnames = ['experimentSetID'] + list(mc.results) writer = csv.DictWriter(csvfile, fieldnames=fieldnames) writer.writeheader() first_time = False os.makedirs('results/' + filename + '_figures') writer.writerow({**{'experimentSetID': str(i)}, **mc.results}) # Save MSD raw data with open( 'results/' + filename + '_figures/nc' + str(Nc) + 'msd_data.csv', 'w') as rawdata: rowwriter = csv.writer(rawdata) for msd_data in mc.results['monomersMSD'].transpose(): rowwriter.writerow(msd_data) # Save MSD curve plt.figure() plt.plot(mc.results['monomersMSD'].transpose()) legend = ['_o'] * polymerParams['numMonomers'] legend[simulationParams['A1']] = 'a1' legend[simulationParams['A1'] + 1] = 'a2' legend[simulationParams['B1']] = 'b1' legend[simulationParams['B1'] + 1] = 'b2' legend = tuple(legend) plt.legend(legend) plt.savefig('results/' + filename + '_figures/nc' + str(Nc) + '.png') plt.close()
def proba_v_gNc(polymerParams, simulationParams, x_g, x_Nc, errorbars=False): date = strftime("%Y_%m_%d_%H_%M") filename = date + '_proba-v_gNc_withVE' + '.csv' first_time = True N = polymerParams['numMonomers'] with open('results/' + filename, 'w') as csvfile: for i, g in enumerate(x_g): print("Simulation for g = %s " % g) simulationParams['genomicDistance'] = g for j, nc in enumerate(x_Nc): print("Simulation for Nc = %s " % nc) polymerParams['Nc'] = nc ### ADAPTIVE ENCOUNTER DISTANCE xi = 2 * (nc + simulationParams['Nc_inDamageFoci']) / ( (N - 1) * (N - 2)) # scaleFactor = np.sqrt( (1-xi0)*np.sqrt(xi0) / ((1-xi)*np.s1qrt(xi)) ) simulationParams['encounterDistance'] = adaptiveEpsilon( xi, N, polymerParams['b']) # simulationParams['excludedVolumeCutOff'] = 3*simulationParams['encounterDistance'] ### ADAPTIVE dt simulationParams['dt'] = np.round( (0.2 * simulationParams['encounterDistance'])**2 / (2 * simulationParams['diffusionConstant']), decimals=4) - 0.0001 simulationParams['numMaxSteps'] = int(60 // simulationParams['dt']) print("ε = %s" % (simulationParams['encounterDistance'])) p0 = RCLPolymer(**polymerParams) simulationParams['waitingSteps'] = np.ceil( p0.relaxTime(simulationParams['diffusionConstant']) / simulationParams['dt_relax']).astype(int) results = {**polymerParams, **simulationParams} mc = Experiment(p0, results, simulationParams, "EncounterSimulation") if first_time: fieldnames = ['experimentSetID'] + list(mc.results) writer = csv.DictWriter(csvfile, fieldnames=fieldnames) writer.writeheader() first_time = False writer.writerow({ **{ 'experimentSetID': str(i) + '_' + str(j) }, **mc.results })
def stats_vs_Nb(polymerParams, simulationParams, x_Nb, x_g): date = strftime("%Y_%m_%d_%H_%M") filename = date + '_StatsVsNb' + '.csv' first_time = True with open('results/' + filename, 'w') as csvfile: for i, Nb in enumerate(x_Nb): print("Simulation for Nb = %s breaks " % Nb) simulationParams['Nb'] = Nb for j, g in enumerate(x_g): simulationParams['genomicDistance'] = g print("and g = %s . " % g) p0 = RCLPolymer(**polymerParams) simulationParams['waitingSteps'] = np.ceil( p0.relaxTime(simulationParams['diffusionConstant']) / simulationParams['dt_relax']).astype(int) results = {**polymerParams, **simulationParams} mc = Experiment(p0, results, simulationParams, "EncounterSimulation") if first_time: fieldnames = ['experimentSetID'] + list(mc.results) writer = csv.DictWriter(csvfile, fieldnames=fieldnames) writer.writeheader() first_time = False writer.writerow({ **{ 'experimentSetID': str(i) + "_" + str(j) }, **mc.results })
def trackAlpha_v_gNc(polymerParams, simulationParams, x_g, x_Nc): date = strftime("%Y_%m_%d_%H_%M") filename = date + '_trackMSD' + '.csv' first_time = True N = polymerParams['numMonomers'] with open('results/' + filename, 'w') as csvfile: for i, g in enumerate(x_g): print("Simulation for g = %s " % g) simulationParams['genomicDistance'] = g for j, nc in enumerate(x_Nc): print("Simulation for Nc = %s " % nc) polymerParams['Nc'] = nc p0 = RCLPolymer(**polymerParams) simulationParams['waitingSteps'] = np.ceil( p0.relaxTime(simulationParams['diffusionConstant']) / simulationParams['dt_relax']).astype(int) results = {**polymerParams, **simulationParams} mc = Experiment(p0, results, simulationParams, "trackMSD") if first_time: fieldnames = ['experimentSetID'] + list(mc.results) writer = csv.DictWriter(csvfile, fieldnames=fieldnames) writer.writeheader() first_time = False writer.writerow({ **{ 'experimentSetID': str(i) + '_' + str(j) }, **mc.results })