ready to publish code

This commit is contained in:
2024-09-08 18:28:14 +08:00
parent bf1c864823
commit 078f20eb38
4 changed files with 12 additions and 8 deletions

View File

@@ -2,7 +2,7 @@ from dragon import *
kBegPitch = 0.3 kBegPitch = 0.3
kEndPitch = 0.55 kEndPitch = 0.55
kTotalSteps = 10000 kTotalSteps = 250000
kStepPitch = (kEndPitch - kBegPitch) / kTotalSteps kStepPitch = (kEndPitch - kBegPitch) / kTotalSteps
kParallelNum=24 kParallelNum=24
tasks_list = [kBegPitch + kStepPitch * i for i in range(kTotalSteps)] tasks_list = [kBegPitch + kStepPitch * i for i in range(kTotalSteps)]
@@ -19,6 +19,8 @@ def ProcessEntryPoint(arg):
status = CheckCollision(status2blocks(dragen.CalcMoveList())) status = CheckCollision(status2blocks(dragen.CalcMoveList()))
tmp_res[pitch]=status tmp_res[pitch]=status
print(f"res={status}",file=logf) print(f"res={status}",file=logf)
if status == -1:
break
with lock: # 添加锁保护对共享字典的操作 with lock: # 添加锁保护对共享字典的操作
shared_dict.update(tmp_res) shared_dict.update(tmp_res)

View File

@@ -1,7 +1,7 @@
from dragon import * from dragon import *
kBegPitch = 0.45033 kBegPitch = 0.45033
kEndPitch = 0.45034 kEndPitch = 0.45034
kTotalSteps = 1000 kTotalSteps = 10
kStepPitch = (kEndPitch - kBegPitch) / kTotalSteps kStepPitch = (kEndPitch - kBegPitch) / kTotalSteps
kParallelNum=24 kParallelNum=24
tasks_list = [kBegPitch + kStepPitch * i for i in range(kTotalSteps)] tasks_list = [kBegPitch + kStepPitch * i for i in range(kTotalSteps)]
@@ -9,7 +9,7 @@ task_list_per_process=[tasks_list[i::kParallelNum] for i in range(kParallelNum)]
kDeltaThetaBeg=0 kDeltaThetaBeg=0
kDeltaThetaEnd=5*2*3.1415926 kDeltaThetaEnd=5*2*3.1415926
kStepDeltaTheta=(kDeltaThetaEnd-kDeltaThetaBeg)/100 kStepDeltaTheta=(kDeltaThetaEnd-kDeltaThetaBeg)/10000
print(f"len(task_list_per_thread)={len(task_list_per_process)}",file=sys.stderr) print(f"len(task_list_per_thread)={len(task_list_per_process)}",file=sys.stderr)
def ProcessEntryPoint(arg): def ProcessEntryPoint(arg):
pitch_list, process_id, shared_dict, lock = arg pitch_list, process_id, shared_dict, lock = arg

View File

@@ -10,8 +10,6 @@ for i in np.arange(10, 20, 1/1000):
tasks_list.append(i) tasks_list.append(i)
for i in np.arange(12, 14.2, 1/10000): for i in np.arange(12, 14.2, 1/10000):
tasks_list.append(i) tasks_list.append(i)
for i in np.arange(13,13.2,1/100000):
tasks_list.append(i)
for i in np.arange(13.085,13.095,1/1000000): for i in np.arange(13.085,13.095,1/1000000):
tasks_list.append(i) tasks_list.append(i)
task_list_per_process=[tasks_list[i::kParallelNum] for i in range(kParallelNum)] task_list_per_process=[tasks_list[i::kParallelNum] for i in range(kParallelNum)]

View File

@@ -1,5 +1,6 @@
import matplotlib.pyplot as plt import matplotlib.pyplot as plt
import numpy as np import numpy as np
import mpmath as mp
kPitch = 1.7 kPitch = 1.7
kAlpha = kPitch / (2 * np.pi) kAlpha = kPitch / (2 * np.pi)
@@ -8,7 +9,12 @@ kCriticalRadius = 4.5
theta_max = (kCriticalRadius) / kAlpha + 2 * 2 * np.pi theta_max = (kCriticalRadius) / kAlpha + 2 * 2 * np.pi
kPlotingRadius = theta_max * kAlpha kPlotingRadius = theta_max * kAlpha
kCriticalTheta = 2.86 / ((2 / 3) * kAlpha) def f(x):
r=(1/3)*kAlpha*mp.sqrt(1+x**2)
phi=mp.atan(x)
L=mp.mpf("2.86")
return (r+3*r*mp.cos(mp.pi-2*phi)-L)**2+(3*r*mp.sin(mp.pi-2*phi))**2-L**2
kCriticalTheta = float(mp.findroot(f, 15, solver='secant'))
# 生成角度数组 # 生成角度数组
theta = np.linspace(kCriticalTheta, theta_max, 1000) theta = np.linspace(kCriticalTheta, theta_max, 1000)
@@ -80,7 +86,5 @@ theta_grid = np.arctan2(Y, X)
valid_points = r_grid <= kPlotingRadius valid_points = r_grid <= kPlotingRadius
ax.scatter(theta_grid[valid_points], r_grid[valid_points], color='grey', s=10) # 灰色小点 ax.scatter(theta_grid[valid_points], r_grid[valid_points], color='grey', s=10) # 灰色小点
plt.title("The Moving Path")
# 显示图像 # 显示图像
plt.show() plt.show()