Bandwidth_fixed = zeros_like(Vr) gain_max = zeros_like(Vr) gain_max_fixed = zeros_like(Vr) gain_bandwidth_product = zeros_like(Vr) gain_bandwidth_product_fixed = zeros_like(Vr) HH_RC = [] for i, V in enumerate(Vr): label_str = str(V) + ' mV' DepolarisePhotoreceptor.WithLight(HH, V) gain_max[i], Bandwidth[i] = Gain_Bandwidth(HH.body.voltage_contrast_gain, f_min=f_medium) gain = abs(HH.body.voltage_contrast_gain(f)) gain_bandwidth_product[i] = gain_max[i] * Bandwidth[i] Experiment.freeze_conductances(HH) gain_max_fixed[i], Bandwidth_fixed[i] = Gain_Bandwidth( HH.body.voltage_contrast_gain, f_min=f_medium) gain_fixed = abs(HH.body.voltage_contrast_gain(f)) gain_bandwidth_product_fixed[i] = gain_max_fixed[i] * Bandwidth_fixed[i] Experiment.unfreeze_conductances(HH) ax_bwprod.plot(V, gain_bandwidth_product[i], colour_graph[i] + '.',
gain_max_shift = zeros_like(Vr) gain_f = zeros_like(Vr) gain_f_shift = zeros_like(Vr) Vr_new = zeros_like(Vr) for i, V in enumerate(Vr): label_str = str(V) + ' mV' DepolarisePhotoreceptor.WithLight(photoreceptor, V=V) Z = photoreceptor.body.impedance(f) #All frequencies ax_Z.loglog(f, abs(Z) / 1000, colour_graph[i] + '--', linewidth=2, label=label_str) pippo, Bandwidth[i] = Gain_Bandwidth(photoreceptor.body.impedance, f_min=f_medium) Cost[i] = photoreceptor.energy_consumption() * delta_cost ax_bw.plot(V, Bandwidth[i], colour_graph[i] + '.', markersize=15, alpha=0.5) ax_cost.plot(V, Cost[i], colour_graph[i] + '.', markersize=15, alpha=0.5) ax_bw_cost.plot(Bandwidth[i], Cost[i], colour_graph[i] + '.', markersize=15, alpha=0.5) if V > V_rest:
colour_graph = ['y', 'b', 'g', 'r', 'c'] Bandwidth = zeros_like(Vr) Bandwidth_fixed = zeros_like(Vr) Cost = zeros_like(Vr) Cost_RC = zeros_like(Vr) HH_RC = [] for i, V in enumerate(Vr): if depolarise_with_light: DepolarisePhotoreceptor.WithLight(HH, V, verbose=2) else: DepolarisePhotoreceptor.WithCurrent(HH, V) C = HH.body.C Z = HH.body.impedance(f) #All frequencies pippo, Bandwidth[i] = Gain_Bandwidth(HH.body.impedance, f_min=f_medium) Cost[i] = HH.energy_consumption() print("Cost is ", Cost[i], "ATP/s") Experiment.freeze_conductances(HH) Z_fixed = HH.body.impedance(f) pippo, Bandwidth_fixed[i] = Gain_Bandwidth(HH.body.impedance, f_min=f_medium) Experiment.unfreeze_conductances(HH) HH_RC.append( FlyFactory.PassiveDrosophilaR16WithBandwidth( Bandwidth[i], V, low_limit_frequency=f_medium)) if depolarise_with_light: DepolarisePhotoreceptor.WithLight(HH_RC[i], V) else:
input_r_dark_u = [] input_r_light_u = [] perturbed_ch_ = ["a", "b", "m_order", "g_max", "tau"] perturbation_ = array([0.8, 0.85, 0.9, 0.95, 1.05, 1.1, 1.15, 1.2]) for channel in HH.body.voltage_channels: for perturbed in perturbed_ch_: original = getattr(channel, perturbed) for perturbation in perturbation_: setattr(channel, perturbed, original * perturbation) HH.set_steady_state(V_rest) input_r = HH.body.impedance(0) R = HH.body.resistance() pippo, Bandwidth = Gain_Bandwidth(HH.body.impedance, f_min=0) factor_bw_dark.append(2 * pi * R * HH.body.C * 1e-3 * Bandwidth) factor_dark.append(R / input_r) input_r_dark.append(input_r / 1000) #kOhm -> MOhm DepolarisePhotoreceptor.WithLight(HH, V_light) input_r = HH.body.impedance(0) R = HH.body.resistance() pippo, Bandwidth = Gain_Bandwidth(HH.body.impedance, f_min=0) factor_bw_light.append(2 * pi * R * HH.body.C * 1e-3 * Bandwidth) factor_light.append(R / input_r) input_r_light.append(input_r / 1000) #kOhm -> MOhm setattr(channel, perturbed, original) original = HH.body.leak_conductances['K'].g_max
###### CONTINUOUS ACROSS VOLTAGES Vr = arange(-60.0,-36.9,0.1) cost = zeros_like(Vr) good_estimation = zeros_like(Vr) estimated_cost_from_peak = zeros_like(Vr) estimated_cost_from_ir = zeros_like(Vr) total_K_conductance = zeros_like(Vr) for i,V in enumerate(Vr): #Impedances at lowest frequency DepolarisePhotoreceptor.WithLight(HH,V) cost[i] = HH.energy_consumption() R = HH.body.resistance() # Good estimation! (Cheating) good_estimation[i] = classic_cost_estimation(R,V,E_K,E_L) R,pippo = Gain_Bandwidth(HH.body.impedance) # R estimated as peak impedance. Wrong! estimated_cost_from_peak[i] = classic_cost_estimation(R,V,E_K,E_L) R = abs(HH.body.impedance(0)) # R estimated as input resistance. Even worse! estimated_cost_from_ir[i] = classic_cost_estimation(R,V,E_K,E_L) semilogy(Vr,cost) semilogy(Vr,estimated_cost_from_ir,'--') semilogy(Vr,estimated_cost_from_peak,'--') if option_debugging: semilogy(Vr,good_estimation,'--') xlabel("Voltage (mV)") ylabel("Cost (ATP/s)") title("Photoreceptor cost at different light levels") show()
f = arange(1.5, 900, delta_f) f_from_medium = arange(f_medium, 500, 1) colour_graph = ['b', 'g', 'r', 'c'] Bandwidth = zeros_like(Vr) Cost = zeros_like(Vr) Cost_RC = zeros_like(Vr) HH_RC = [] for i, V in enumerate(Vr): DepolarisePhotoreceptor.WithLight(HH, V, verbose=2) C = HH.body.C Z = HH.body.impedance(f) #All frequencies Cost[i] = HH.energy_consumption() pippo, Bandwidth[i] = Gain_Bandwidth(HH.body.impedance, f_min=f_medium) HH_RC.append( FlyFactory.PassiveCalliphoraR16WithBandwidth( Bandwidth[i], V, low_limit_frequency=f_medium)) DepolarisePhotoreceptor.WithLight(HH_RC[i], V) Cost_RC[i] = HH_RC[i].energy_consumption() Z_RC = HH_RC[i].body.impedance(f) #All frequencies total_K_conductance = HH.body.total_voltage_dependent_conductance( ) + HH.body.leak_conductances['K'].g() total_depol_conductance = HH.body.leak_conductances['L'].g( ) + HH.body.light_conductance.g() print( "At voltage {} mV, the active ph membrane has total K conductance {:04.2E} mS and total depolarising conductance {:04.2E} mS" .format(V, total_K_conductance, total_depol_conductance))