Hey Guys!
I have a problem with generating a geometry. I want to analyze a lubrication gab of a journal bearing. Instead od just using two cylinders, I want to look at the unfolded geometry because further use would be much more simple.
Generating the main structure isn’t a problem. The problem comes with creating small bores in the structure. I basically want it to look like the first attached picture (I don’t know, why there are red areas shining through). Just unfolded. My problem is, that the “Dimples” ar not created correctly. They get cut or simply not generated. This is shown in the second picture. Sometimes, instead of a Dimple I get a hole in my geometry.
Does anyone have a suggestion on how to fix my problem?
Thank you for your help!
from netgen.occ import *
import pyngcore as ngcore
from ngsolve import *
import numpy as np
import math
import sys
import time
from netgen import *
### Bearing ------------------------------------------------------
# Diameter [m]
# D = 2
# D = 30 * 10**-3
D = 10 * 10**-3
R = D/2
# Width [m]
# b = 1.0
# b = D
b = 5 * 10**-3
### Shaft --------------------------------------------------------
# Diameter [m]
# d = 1.5
# d = 29.94 * 10**-3
d = D * (1 - 0.002)
r = d/2
# relative Excentricity [-]
# epsilon = 0.6
epsilon = 0.6
# Excentricity [m]
e = epsilon * (R - r)
### Small Dimples ------------------------------------------------
# Diameter [m]
# d_d = 0.1
d_d = 0.1 * 10**-3
r_d = d_d/2
# Depth [m]
# h_d = 0.02
h_d = 100 * 10**-6
# Start of holes measured from negative y-Axis [°]
phi_start = -45
# End of holes measured from negative y-Axis [°]
phi_end = 45
# Angle between holes [°]
phi_distance = 5
# Rows [-]
rows = 3
# Angle between rows [°]
row_angle = 2.5
### Mesh ----------------------------------------------------------
# Max mesh size
max_mesh = 0.1 * 10**-3
# Processors for usage
numProc = 24
def generateGeometry(R, r, b, e, r_d, h_d, phi_start, phi_end, phi_distance, rows, row_angle, max_mesh, numProc):
# Define start point and direction of 1st cylinder
start_point = gp_Pnt(0, 0, 0)
direction = gp_Dir(0, 0, 1)
# Create 1st cylinder and name outside
cylinder_1 = Cylinder(gp_Ax2(start_point, direction), R, b)
cylinder_1.faces[0].name = 'outside'
cylinder_1.faces.Min(Z).name = 'back'
cylinder_1.faces.Max(Z).name = 'front'
cylinder_combined = cylinder_1
# Get angle array for further computations
phi_start = phi_start * math.pi / 180
phi_end = phi_end * math.pi / 180
phi_distance = phi_distance * math.pi / 180
row_angle = row_angle * math.pi / 180
phi = np.arange(phi_start, phi_end, phi_distance)
if round((phi[-1] + phi_distance)*10**10) <= round(phi_end*10**10):
phi = np.append(phi, phi[-1] + phi_distance)
# Get spaces between rows
row_space = b / (rows + 1)
cylinder_row = []
cylinder_row.append(row_space)
for i in range(rows - 1):
next_space = cylinder_row[i] + row_space
cylinder_row.append(next_space)
# Create Dimples
for i in range(len(cylinder_row)):
start_point_d = []
cylinder_d = []
direction_d = []
# Starting points of Dimples
phi_current = np.arange(phi_start + (i * row_angle) % phi_distance, phi_end, phi_distance)
if round((phi_current[-1] + phi_distance)*10**10) <= round(phi_end*10**10):
phi_current = np.append(phi_current, phi_current[-1] + phi_distance)
# Position and direction of Dimples
for angle in phi_current:
start_point_d.append(gp_Pnt(0.5 * R * math.sin(angle), -0.5 * R * math.cos(angle), cylinder_row[i]))
direction_d.append(gp_Dir(math.sin(angle),-math.cos(angle), 0))
# Create Dimples and name faces
for j in range(len(start_point_d)):
cylinder_d.append(Cylinder(gp_Ax2(start_point_d[j], direction_d[j]), r_d, h_d + 0.5 * R))
#cylinder_s[j].faces[0].col = (0, 0, 1)
cylinder_d[j].faces[0].name = 'dimple_walls'
#cylinder_s[j].faces[1].col = (0, 0, 1)
cylinder_d[j].faces[1].name = 'outside'
cylinder_combined = cylinder_combined + cylinder_d[j]
# geo_trial = OCCGeometry(cylinder_combined)
# Draw(geo_trial)
# Define start point and direction of Hole
start_point_2 = gp_Pnt(0, -e, 0)
direction_2 = gp_Dir(0, 0, 1)
# Create Hole and name Inside
cylinder_2 = Cylinder(gp_Ax2(start_point_2, direction_2), r, b)
cylinder_2.faces.Max(Y).name = 'inside'
# Final Geometry
cylinder_combined = cylinder_combined - cylinder_2
geo = OCCGeometry(cylinder_combined)
for face in geo.shape.faces:
if face.name == 'inside':
face.col = (1, 0, 0)
if face.name == 'outside':
face.col = (0, 0, 1)
if face.name == 'back' or face.name == 'front':
face.col = (1, 0, 1)
if face.name == 'dimple_walls':
face.col = (1, 1, 0)
print('Finished')
return geo
geo = generateGeometry(R, r, b, e, r_d, h_d, phi_start, phi_end, phi_distance, rows, row_angle, max_mesh, numProc)
Draw(geo)