怎么在以下代码中添加每隔100时间步输出相应运行图片的代码,最好是直接添加的回答
```python
import numpy as np
import matplotlib.pyplot as plt
import copy
from create_block import Createblock
from bounce_back import Bounce_back
import matplotlib.animation as animation
import time
import math
import subprocess
H = 400 # height
W = 400 # width
MAX_T = 1000 # max_time
psi_wall = -0.5 # wettability on block and wall
Pe = 15 # Peclet numbernet
C_W = 1.5 * 10 ** (-7) # top width
Ca = 2.0 * 7.33 * 10 ** (-3) # Capillary number
M = 20.0 # Eta non_newtonian / Eta newtonian
Eta = 0.001
def main():
cr = Createblock(H, W)
bb = Bounce_back(H, W)
mabiki = MAX_T // 100
circle_list = []
r = 10
xx = 10
count = 1
z = r + xx - 25
while True:
if count * (xx + r) - z > 380:
break
for i in range(block_num):
circle_list.append(((count * (r + xx) - z, (2 * i + 1) * (r + xx)), r))
count += 2
circle_list2 = []
count = 1
while True:
if count * (xx + r) - z > 0:
break
for i in range(block_num):
circle_list2.append(((count * (r + xx) - z, (2 * i + 1) * (r + xx)), r + 1))
count += 2
block_psi_all, side_list, concave_list, convex_list = cr.setCirleblock(circle_list)
block_mask = np.where(block_psi_all == 1, True, False)
mask = np.logical_not(block_mask)
cm = Compute(mask)
cc = np.array([cm.psi])
for i in range(MAX_T):
for j in range(9):
cm.F[j] = cm.getLarge_F(j)
cm.feq[j] = cm.getfeq(j)
cm.geq[j] = cm.getgeq(j)
cm.f[j][mask] = cm.getF(j)
cm.g[j][mask] = cm.getG(j)
print("timestep:{}".format(i))
f_behind = copy.deepcopy(cm.f)
g_behind = copy.deepcopy(cm.g)
stream(cm.f, cm.g)
bb.halfway_bounceback_circle(side_list, concave_list, convex_list, f_behind, g_behind, cm.f, cm.g)
cm.zou_he_boundary_inlet()
cm.zou_he_boundary_outlet()
cm.rho = cm.getRho()
cm.udpatePsi()
cm.nabla_psix = cm.getNabla_psix()
cm.nabla_psiy = cm.getNabla_psiy()
cm.nabla_psi2 = cm.getNabla_psi2()
cm.mu = cm.getMu()
cm.ux = cm.getUx()
cm.uy = cm.getUy()
cm.p = cm.getP()
cm.mix_tau = cm.getMix_tau()
def animate(frame):
y = [i for i in range(H)]
x = [i for i in range(W)]
plt.figure()
plt.pcolor(x, y, cm.psi, cmap='RdBu')
plt.colorbar()
plt.gca().set_aspect('equal', adjustable='box')
plt.show()
if __name__ == '__main__':
np.seterr(all='raise')
try:
t1 = time.time()
main()
t2 = time.time()
print((t2 - t1) / 60)
#自动上传
except Warning as e:
print(e)
```
这个Createblock 模块是什么?下面导入几个都是自己写的模块吗?
这边没有很理解楼主的意思,但是可以考虑用 pygame 的每秒刷新来做
1.设已知数据集为(X,Y),假设其线性关系为:
y_pred=hθ(x)=θ0+θ1×x y\_pred=h_{\theta}\left( x \right) =\theta _0+\theta _1\times x y_pred=hθ(x)=θ0+θ1×x
2.用均平方误差(MSE)作为代价函数(损失函数),其中m为样本数:
J(x,y,θ)(MSE)=12m∑i=1m(hθ(x(i))−y(i))2 ^{J(x,y,\theta )(MSE)=\frac{1}{2m}\sum_{i=1}^m{\left( h_{\theta}\left( x^{\left( i \right)} \right) -y^{^{\left( i \right)}} \right) ^2}} J(x,y,θ)(MSE)=2m1∑i=1m(hθ(x(i))−y(i))2