本文整理汇总了Python中Simulation.set_initial_conditions方法的典型用法代码示例。如果您正苦于以下问题:Python Simulation.set_initial_conditions方法的具体用法?Python Simulation.set_initial_conditions怎么用?Python Simulation.set_initial_conditions使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Simulation
的用法示例。
在下文中一共展示了Simulation.set_initial_conditions方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: u
# 需要导入模块: import Simulation [as 别名]
# 或者: from Simulation import set_initial_conditions [as 别名]
rl_connect = (i % ncolumns == ncolumns - 1 and j % ncolumns == 0)
if lr_connect or rl_connect:
# we're connecting boundaries
dx = dx - ncolumns
Dmat[i,j] = dx ** 2 + dy ** 2
# add diffusion to h and u
# try using custom square distance matrix for period BC
sim.add_interaction('h','h','diffusion',connections,params=([Dh/Th],Dmat))
sim.add_interaction('u','u','diffusion',connections,params=([Du/Tu],Dmat))
# start with only first cell up
low_dict = {'a':0.0,'s':0.0,'h':0.0,'u':0.0}
med_dict = {'a':0.0,'s':0.0,'h':0.015,'u':4e-6} # start with some h and u in template
high_dict = {'a':1.0+F,'s':1.0,'h':0.015,'u':4e-6} # start with some h and u (0.015 ss)
sim.set_initial_conditions(range(0,NCells),low_dict)
# templating different numbers of rows of R8s
ntemplate = 8
sim.set_initial_conditions(range(0,ncolumns*(4*(ntemplate-1)+1)),med_dict)
high_cells = []
for i in xrange(ntemplate):
if i % 2 == 0:
high_cells += [ncolumns*4*i+4,ncolumns*4*i+12]
else:
high_cells += [ncolumns*4*i,ncolumns*4*i+8]
sim.set_initial_conditions(high_cells,high_dict)
print 'starting simulation'
t = np.linspace(0,400,150)
cdata = sim.simulate(t)
print 'simulation done'
示例2:
# 需要导入模块: import Simulation [as 别名]
# 或者: from Simulation import set_initial_conditions [as 别名]
'''
# no just lateral connections
# cells adjacent to one another are connected
# for activation, don't inlude main diagonal
hill_connections = (np.eye(NCells,k=-1) + np.eye(NCells,k=1)) > 0
# a -> pnt
sim.add_interaction('a','pnt','hill_activ',hill_connections,params=[1.0,1.5,4])
# a -> notch
sim.add_interaction('a','notch','hill_activ',hill_connections,params=[1.5,0.5,2])
'''
# start with only first cell up
low_dict = {'a':0.0,'s':0.0,'h':0.0,'u':0.0,'y':0.0,'p':0.0,'sp':0.0,'m':0.0}
high_dict = {'a':1.0+F,'s':1.0,'h':0.0,'u':0.0,'y':0.0,'p':0.0,'sp':0.0,'m':0.0}
sim.set_initial_conditions(range(0,NCells),low_dict)
sim.set_initial_conditions([0],high_dict)
print 'starting simulation'
t = np.linspace(0,225,100)
cdata = sim.simulate(t)
print 'simulation done'
import matplotlib.pyplot as plt
import matplotlib.cm as cm
import matplotlib.gridspec as gridspec
x_coord = np.linspace(1,NCells,NCells)
# plot species at various times
示例3: InternalModel
# 需要导入模块: import Simulation [as 别名]
# 或者: from Simulation import set_initial_conditions [as 别名]
IM2 = InternalModel()
IM2.add_node('a','linear',params=[0.5])
IM2.add_node('b','linear',params=[1])
eid = IM2.add_edge('b','b','hill_activ',params=[1,1,2])
IM2.add_edge('a',eid,'lin_activ',is_mod=True,mod_type='mult',params=[5])
cell1 = Cell([0])
cell2 = Cell([1])
cell3 = Cell([3])
sim = Simulation()
sim.add_cell(cell1)
sim.add_cell(cell2)
sim.add_cell(cell3)
im_id = sim.add_internal_model(IM)
im_id2 = sim.add_internal_model(IM2)
connections = np.array([[True,True,False],[True,True,True],[False,True,True]])
sim.set_internal_model([0,1],im_id)
sim.set_internal_model([2],im_id2)
sim.add_interaction('a','a','diffusion',connections,params=[1])
sim.set_initial_conditions([0],{'a':0})
sim.set_initial_conditions([1],{'a':6})
sim.set_initial_conditions([2],{'a':0,'b':1})
t = np.linspace(0,10,100)
cdata = sim.simulate(t)
示例4:
# 需要导入模块: import Simulation [as 别名]
# 或者: from Simulation import set_initial_conditions [as 别名]
lr_connect = (i % ncolumns == 0 and j % ncolumns == ncolumns - 1)
rl_connect = (i % ncolumns == ncolumns - 1 and j % ncolumns == 0)
if lr_connect or rl_connect:
# we're connecting boundaries
dx = dx - ncolumns
Dmat[i,j] = dx ** 2 + dy ** 2
# add diffusion to h and u
# try using custom square distance matrix for period BC
sim.add_interaction('h','h','diffusion',connections,params=([Dh/Th],Dmat))
sim.add_interaction('u','u','diffusion',connections,params=([Du/Tu],Dmat))
# start with only first cell up
low_dict = {'a':0.0,'s':0.0,'h':0.0,'u':0.0}
high_dict = {'a':1.0+F,'s':1.0,'h':0.0,'u':0.0}
sim.set_initial_conditions(range(0,NCells),low_dict)
sim.set_initial_conditions([0,1,2,3,4,5,6,8,9,10,11,12,13,14,ncolumns*4+4,ncolumns*4+12],high_dict)
print 'starting simulation'
t = np.linspace(0,350,150)
cdata = sim.simulate(t)
print 'simulation done'
import matplotlib.pyplot as plt
import matplotlib.cm as cm
import matplotlib as mpl
import matplotlib.gridspec as gridspec
from matplotlib.patches import Rectangle
# plot 2D picture
示例5: InternalModel
# 需要导入模块: import Simulation [as 别名]
# 或者: from Simulation import set_initial_conditions [as 别名]
from Simulation import *
import matplotlib.pyplot as plt
# exclusive bistability test:
# two nodes inhibiting one another
IM = InternalModel()
IM.add_node('a','linear',[0.2])
IM.add_node('b','linear',[0.2])
IM.add_edge('a','b','hill_inactiv',params=[2.0,2.0,2.0,2])
IM.add_edge('b','a','hill_inactiv',params=[2.0,2.0,2.0,2])
cell = Cell()
sim = Simulation()
sim.add_cell(cell)
im_id = sim.add_internal_model(IM)
sim.set_internal_model([0],im_id)
sim.set_initial_conditions([0],{'a':5.0,'b':4.0})
t = np.linspace(0,100,1000)
cdata = sim.simulate(t)
plt.plot(t,cdata[0])
plt.legend(['a','b'])
plt.show()
示例6:
# 需要导入模块: import Simulation [as 别名]
# 或者: from Simulation import set_initial_conditions [as 别名]
connections[i,j] = False
# calculate custom square distance matrix for periodic boundary conditions on diffusion
Dmat = lattice.get_periodic_dmat(nrows,ncolumns)
# add diffusion to h and u
# try using custom square distance matrix for period BC
sim.add_interaction('h','h','diffusion',connections,params=([Dh/Th],Dmat))
sim.add_interaction('u','u','diffusion',connections,params=([Du/Tu],Dmat))
# start with only first R8 row up
h_const = 0.016
low_dict = {'a':0.0,'s':0.0,'h':0.0,'u':0.0}
first_low_dict = {'a':0.0,'s':0.0,'h':h_const,'u':0.0} # for first row h
high_dict = {'a':1.0+F,'s':1.0,'h':h_const,'u':0.0} # template row has source h
sim.set_initial_conditions(range(ncolumns,NCells),low_dict)
sim.set_initial_conditions(range(ncolumns),first_low_dict)
sim.set_initial_conditions([4,12],high_dict) # [4,12]
print 'starting simulation'
t = np.linspace(0,250,150)
cdata = sim.simulate(t)
print 'simulation done'
# save to pickle file with same name as script
pickle_file = os.path.basename(__file__).split('.')[0] + '.p'
saving.save(pickle_file,t=t,cdata=cdata,centers=centers,sim=sim)
# reload for plotting
PH = plotting.PlotHelper.from_file(pickle_file)
示例7: InternalModel
# 需要导入模块: import Simulation [as 别名]
# 或者: from Simulation import set_initial_conditions [as 别名]
# some testing
IM = InternalModel()
IM.add_node('a','linear',[5])
IM.add_node('b','parabolic',[0.5])
eid = IM.add_edge('a','a','const_prod',params=[2])
IM.add_edge('b',eid,'lin_activ',is_mod=True,mod_type='mult',params=[10])
IM2 = InternalModel()
IM2.add_node('c','parabolic',[2])
IM2.add_edge('c','c','hill_activ',params=[3,1,2])
cell1 = Cell()
cell2 = Cell()
cell3 = Cell()
sim = Simulation()
sim.add_cell(cell1)
sim.add_cell(cell2)
sim.add_cell(cell3)
im_id = sim.add_internal_model(IM)
im2_id = sim.add_internal_model(IM2)
sim.set_internal_model([0,1],im_id)
sim.set_initial_conditions([0],{'a':5,'b':5})
sim.set_initial_conditions([1],{'a':10,'b':10})
sim.set_internal_model([2],im2_id)
sim.set_initial_conditions([2],{'c':0.2})
t = np.linspace(0,10,100)
cdata = sim.simulate(t)