Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to solve the error #1559

Open
binfengjiao opened this issue Apr 11, 2024 · 3 comments
Open

How to solve the error #1559

binfengjiao opened this issue Apr 11, 2024 · 3 comments
Labels

Comments

@binfengjiao
Copy link

How to solve the error in the picture? The specific content of the reference function is as follows:
def bcc_heterogeneous_lattice(unit_cell_size,
min_strut_diameter,
max_strut_diameter,
min_node_diameter,
max_node_diameter,
Nx, Ny, Nz,
topology='bcc',
rule='linear',
position=(0, 0, 0),
rotation=(0, 0, 0)):
if topology not in ['bcc', 'bccz', 'sbcc', 'sbccz']:
raise TypeError(f'The type '{topology}' does not exist!')
min_strut_radius = min_strut_diameter / 2.0
max_strut_radius = max_strut_diameter / 2.0
if rule == 'linear':
strut_radii = np.linspace(min_strut_radius,
max_strut_radius,
Nz)
node_diameters = np.linspace(min_node_diameter,
max_node_diameter,
Nz)
if rule == 'sin':
average = lambda num1, num2: (num1 + num2) / 2
strut_radii = np.sin(
np.linspace(min_strut_radius, max_strut_radius, Nz) * 12) + 2 * average(min_strut_radius, max_strut_radius)
node_diameters = np.sin(
np.linspace(min_node_diameter, max_node_diameter, Nz) * 12) + 2 * average(min_node_diameter,
max_node_diameter)
if rule == 'parabola':
x = np.linspace(0, 1, num=Nz)
frep = lambda d_min, d_max: -4 * d_max * (x - 0.5) * (x - 0.5) + d_max + d_min
strut_radii = frep(min_strut_radius, max_strut_radius)
print(strut_radii)
node_diameters = frep(min_node_diameter, max_node_diameter)
UC_pnts = []
for i in range(Nx):
for j in range(Ny):
for k in range(Nz):
UC_pnts.append((i * unit_cell_size, j * unit_cell_size, k * unit_cell_size))
print("Datapoints generated")
result = cq.Workplane().tag('base').transformed(
offset=cq.Vector(position[0], position[1], position[2]),
rotate=cq.Vector(rotation[0], rotation[1], rotation[2]))
result = result.pushPoints(UC_pnts)
unit_cell_params = []
for i in range(Nx * Ny):
for j in range(Nz):
unit_cell_params.append({"unit_cell_size": unit_cell_size,
"strut_radius": strut_radii[j],
"node_diameter": node_diameters[j],
"type": topology})
result = result.eachpointAdaptive(unit_cell,
callback_extra_args=unit_cell_params,
useLocalCoords=True)
print("The lattice is generated")
return result

1

2
error

@huskier
Copy link
Contributor

huskier commented Apr 15, 2024

I’m very curious what the no_MRE stands for? I guess it's no Minimal Reproducible Example (no_MRE). Right?

@adam-urbanczyk
Copy link
Member

Indeed, you are right.

@huskier
Copy link
Contributor

huskier commented Apr 15, 2024

Thanks. @adam-urbanczyk

@binfengjiao You may firstly put the code inside the CODE BLOCK. You'd better to make a MRE to pinpoint the issue.

[the code]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants