<jupyter_start><jupyter_text>Validating the Surface ClassIn this file we attempt to convince ourselves that the class Surface is doing what we think it is doing.  Test 1: Circular axis, circular cross-sectionLet's start by plotting this surface.<jupyter_code>import sys
sys.path.append("..")
import numpy as np
import focusadd
from focusadd.surface.Surface import Surface
import numpy as np
import mayavi as maya
from mayavi import mlab
mlab.init_notebook()
mlab.clf()
surface = Surface("../focusadd/initFiles/axes/circularAxis.txt", 64, 32, 1.0)
r = surface.get_r()
x = r[:,:,0]
y = r[:,:,1]
z = r[:,:,2]
s = mlab.mesh(x,y,z,colormap="bone")
s<jupyter_output><empty_output><jupyter_text>Now let's plot the normal vector on this surface.<jupyter_code>nn = surface.get_nn()
r_central = surface.get_r_central()
x2 = r_central[:,:,0]
y2 = r_central[:,:,1]
z2 = r_central[:,:,2]
nn_x = nn[:,:,0]
nn_y = nn[:,:,1]
nn_z = nn[:,:,2]
n = mlab.quiver3d(x2[::,::],y2[::,::],z2[::,::],nn_x[::,::],nn_y[::,::],nn_z[::,::])
n<jupyter_output><empty_output><jupyter_text>Seems right. Now let's plot the surface normals in proportion to their surface area. We should see that the outer part of the torus has larger surface area than the inner portion.<jupyter_code>mlab.clf()
s = mlab.mesh(x,y,z,colormap="bone")
nn = surface.get_nn()
nnA = nn * surface.get_sg()[:,:,np.newaxis]
nn_x2 = nnA[:,:,0]
nn_y2 = nnA[:,:,1]
nn_z2 = nnA[:,:,2]
s = mlab.quiver3d(x2[::,::],y2[::,::],z2[::,::],nn_x2[::,::],nn_y2[::,::],nn_z2[::,::])
s<jupyter_output><empty_output><jupyter_text>Test 2: Default axis, circular cross-section Let's perform the same checks on the default axis.<jupyter_code>mlab.clf()
surface = Surface("../focusadd/initFiles/axes/defaultAxis.txt", 64, 32, 1.0)
r = surface.get_r()
x = r[:,:,0]
y = r[:,:,1]
z = r[:,:,2]
s = mlab.mesh(x,y,z,colormap="bone")
s
nn = surface.get_nn()
r_central = surface.get_r_central()
x2 = r_central[:,:,0]
y2 = r_central[:,:,1]
z2 = r_central[:,:,2]
nn_x = nn[:,:,0]
nn_y = nn[:,:,1]
nn_z = nn[:,:,2]
n = mlab.quiver3d(x2[::,::],y2[::,::],z2[::,::],nn_x[::,::],nn_y[::,::],nn_z[::,::])
n
mlab.clf()
s = mlab.mesh(x,y,z,colormap="bone")
nn = surface.get_nn()
nnA = nn * surface.get_sg()[:,:,np.newaxis]
nn_x2 = nnA[:,:,0]
nn_y2 = nnA[:,:,1]
nn_z2 = nnA[:,:,2]
s = mlab.quiver3d(x2[::,::],y2[::,::],z2[::,::],nn_x2[::,::],nn_y2[::,::],nn_z2[::,::])
s<jupyter_output><empty_output><jupyter_text>Test 3: Non-Rotating Ellipse<jupyter_code>mlab.clf()
surface = Surface("../focusadd/initFiles/axes/ellipticalAxisNoRotate.txt", 64, 32, 1.0)
r = surface.get_r()
x = r[:,:,0]
y = r[:,:,1]
z = r[:,:,2]
s = mlab.mesh(x,y,z,colormap="bone")
s
nn = surface.get_nn()
r_central = surface.get_r_central()
x2 = r_central[:,:,0]
y2 = r_central[:,:,1]
z2 = r_central[:,:,2]
nn_x = nn[:,:,0]
nn_y = nn[:,:,1]
nn_z = nn[:,:,2]
n = mlab.quiver3d(x2[::,::],y2[::,::],z2[::,::],nn_x[::,::],nn_y[::,::],nn_z[::,::])
n
mlab.clf()
s = mlab.mesh(x,y,z,colormap="bone")
nn = surface.get_nn()
nnA = nn * surface.get_sg()[:,:,np.newaxis]
nn_x2 = nnA[:,:,0]
nn_y2 = nnA[:,:,1]
nn_z2 = nnA[:,:,2]
s = mlab.quiver3d(x2[::,::],y2[::,::],z2[::,::],nn_x2[::,::],nn_y2[::,::],nn_z2[::,::])
s<jupyter_output><empty_output><jupyter_text>Test 4: Rotating Ellipse<jupyter_code>mlab.clf()
surface = Surface("../focusadd/initFiles/axes/ellipticalAxis5Rotate.txt", 64, 32, 1.0)
r = surface.get_r()
x = r[:,:,0]
y = r[:,:,1]
z = r[:,:,2]
s = mlab.mesh(x,y,z,colormap="bone")
s
nn = surface.get_nn()
r_central = surface.get_r_central()
x2 = r_central[:,:,0]
y2 = r_central[:,:,1]
z2 = r_central[:,:,2]
nn_x = nn[:,:,0]
nn_y = nn[:,:,1]
nn_z = nn[:,:,2]
n = mlab.quiver3d(x2[::,::],y2[::,::],z2[::,::],nn_x[::,::],nn_y[::,::],nn_z[::,::])
n
mlab.clf()
s = mlab.mesh(x,y,z,colormap="bone")
nn = surface.get_nn()
nnA = nn * surface.get_sg()[:,:,np.newaxis]
nn_x2 = nnA[:,:,0]
nn_y2 = nnA[:,:,1]
nn_z2 = nnA[:,:,2]
s = mlab.quiver3d(x2[::,::],y2[::,::],z2[::,::],nn_x2[::,::],nn_y2[::,::],nn_z2[::,::])
s<jupyter_output><empty_output><jupyter_text>I find these surface normals pretty convincing that the surface class is doing what I think it is. The one function which hasn't been debugged is the calc_r_coils function, but this will be tested when we initialize coils.   Test 5: Surface Area Magnitude  For a circular axis with radius 1, circular cross-section with minor radius 0.1, we should see a total surface area of approximately 2pi(1) * 2pi(.1) = 0.4 pi**2<jupyter_code>mlab.clf()
surface = Surface("../focusadd/initFiles/axes/circularAxis.txt", 64, 32, 1.0)
sg = surface.get_sg()
A = np.sum(sg)
print(A)
print(.4 * 3.141**2)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.25237273511647973, 'fraction_numerical': 0.0362381363244176, 'mean_word_length': 6.443017656500802, 'pattern_counts': {'":': 0, '<': 29, '<?xml version=': 0, '>': 29, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '7', 'dir': 'jupyter-structured-clean-dedup', 'id': '257889', 'license': 'BSD-3-Clause', 'n_tokens_mistral': 2235, 'n_tokens_neox': 2201, 'n_words': 405, 'path': 'tests/validate_scripts/ValidateSurface.ipynb', 'repo_name': 'smiet/FOCUSADD', 'size': '4636'}