import itertools
from math import degrees
from string import ascii_uppercase
import numpy as np
from pytekla import wrap
def letters():
n = 1
while True:
yield from (
"".join(group) for group in itertools.product(ascii_uppercase, repeat=n)
)
n += 1
model = wrap("Model.Model")
n_points = 25
radius = np.arange(5000, 25000, 5000)
angles = np.linspace(0, 2 * np.pi, n_points)
degrees_angles = np.array([degrees(x) for x in angles])
n_floors = 5
floor_height = 5000
z_levels = np.arange(
0, floor_height * n_floors + floor_height, floor_height, dtype=float
)
radial_grid = wrap("Model.RadialGrid")
radial_grid.angular_coordinates = " ".join(
str(angle) for angle in np.diff(degrees_angles, prepend=0)
)
radial_grid.coordinate_z = " ".join(str(z) for z in z_levels)
radial_grid.radial_coordinates = " ".join(str(x) for x in radius)
radial_grid.angular_labels = " ".join(itertools.islice(letters(), len(degrees_angles)))
radial_grid.label_z = " ".join(f"+{str(z)}" for z in z_levels)
radial_grid.radial_labels = " ".join(str(i) for i, _ in enumerate(radius, start=1))
radial_grid.insert()
model.commit_changes("Add Radial Grid")