怎么解决python maximum recursion depth exceeded while calling a Python object
程序运行到for Pc in filter_pc:
update_phase_and_phys(OP_1.results(Pc=Pc))
这一步堆栈溢出,按网上的操作修改内存容量或是import sys
sys.setrecursionlimit都不管用,想问一下大家怎么解决这个问题的。
// An highlighted block
data = OP_1.get_intrusion_data()
# Filter for evenly spaced sat inc. first and last
filter_pc = [data.Pcap[0]]
sat = [data.Snwp[0]]
for i, pc in enumerate(data.Pcap):if data.Snwp[i] - sat[-1] > 0.05:filter_pc.append(pc)sat.append(data.Snwp[i])
filter_pc.append(data.Pcap[-1])
sat.append(data.Snwp[-1])
def update_phase_and_phys(results):water['pore.occupancy'] = results['pore.occupancy']air['pore.occupancy'] = 1-results['pore.occupancy']water['throat.occupancy'] = results['throat.occupancy']air['throat.occupancy'] = 1-results['throat.occupancy']# Add multiphase conductancesmode='strict'phys_air.add_model(model=mods.physics.multiphase.conduit_conductance,propname='throat.conduit_diffusive_conductance',throat_conductance='throat.diffusive_conductance',mode=mode)phys_water.add_model(model=mods.physics.multiphase.conduit_conductance,propname='throat.conduit_diffusive_conductance',throat_conductance='throat.diffusive_conductance',mode=mode)phys_air.add_model(model=mods.physics.multiphase.conduit_conductance,propname='throat.conduit_hydraulic_conductance',throat_conductance='throat.hydraulic_conductance',mode=mode)phys_water.add_model(model=mods.physics.multiphase.conduit_conductance,propname='throat.conduit_hydraulic_conductance',throat_conductance='throat.hydraulic_conductance',mode=mode)phys_air_b.add_model(model=mods.physics.multiphase.conduit_conductance,propname='throat.conduit_diffusive_conductance',throat_conductance='throat.diffusive_conductance',mode=mode)phys_water_b.add_model(model=mods.physics.multiphase.conduit_conductance,propname='throat.conduit_diffusive_conductance',throat_conductance='throat.diffusive_conductance',mode=mode)phys_air_b.add_model(model=mods.physics.multiphase.conduit_conductance,propname='throat.conduit_hydraulic_conductance',throat_conductance='throat.hydraulic_conductance',mode=mode)phys_water_b.add_model(model=mods.physics.multiphase.conduit_conductance,propname='throat.conduit_hydraulic_conductance',throat_conductance='throat.hydraulic_conductance',mode=mode)update_phase_and_phys(OP_1.results(Pc=1e3))
perm_air = {
'0': [], '1': [], '2': []}
diff_air = {
'0': [], '1': [], '2': []}
perm_water = {
'0': [], '1': [], '2': []}
diff_water = {
'0': [], '1': [], '2': []}max_Pc = max(OP_1['throat.invasion_pressure'])
print(max_Pc)
num_seq = 20
pore_volumes = sgl['pore.volume']
throat_volumes = sgl['throat.volume']
totV = np.sum(pore_volumes) + np.sum(throat_volumes)K_air_single_phase = [None, None, None]
D_air_single_phase = [None, None, None]
K_water_single_phase = [None, None, None]
D_water_single_phase = [None, None, None]
bounds = [['front', 'back'], ['left', 'right'], ['top', 'bottom']]for bound_increment in range(len(bounds)):# Run Single phase algs effective propertiesBC1_pores = sgl.pores(labels=bounds[bound_increment][0]+'_boundary')BC2_pores = sgl.pores(labels=bounds[bound_increment][1]+'_boundary')# Effective permeability : airsf_air = op.algorithms.StokesFlow(network=sgl, phase=air)sf_air.setup(conductance='throat.hydraulic_conductance')sf_air.set_value_BC(values=0.6, pores=BC1_pores)sf_air.set_value_BC(values=0.2, pores=BC2_pores)sf_air.run()K_air_single_phase[bound_increment] = sf_air.calc_effective_permeability()proj.purge_object(obj=sf_air)# Effective diffusivity : airfd_air = op.algorithms.FickianDiffusion(network=sgl,phase=air)fd_air.setup(conductance='throat.diffusive_conductance')fd_air.set_value_BC(values=0.6, pores=BC1_pores)fd_air.set_value_BC(values=0.2, pores=BC2_pores)fd_air.run()D_air_single_phase[bound_increment] = fd_air.calc_effective_diffusivity()proj.purge_object(obj=fd_air)# Effective permeability : watersf_water = op.algorithms.StokesFlow(network=sgl, phase=water)sf_water.setup(conductance='throat.hydraulic_conductance')sf_water.set_value_BC(values=0.6, pores=BC1_pores)sf_water.set_value_BC(values=0.2, pores=BC2_pores)sf_water.run()K_water_single_phase[bound_increment] = sf_water.calc_effective_permeability()proj.purge_object(obj=sf_water)# Effective diffusivity : waterfd_water = op.algorithms.FickianDiffusion(network=sgl,phase=water)fd_water.setup(conductance='throat.diffusive_conductance')fd_water.set_value_BC(values=0.6, pores=BC1_pores)fd_water.set_value_BC(values=0.2, pores=BC2_pores)fd_water.run()D_water_single_phase[bound_increment] = fd_water.calc_effective_diffusivity()proj.purge_object(obj=fd_water)for Pc in filter_pc:update_phase_and_phys(OP_1.results(Pc=Pc))print('-' * 80)print('Pc', Pc)