# Creating a spherical array

Keep in mind that I am almost completely new to blender.

I was wondering how to create a spherical array. I have Googled and Googled, but I can only find ways to make circular arrays (two dimensional arrays). Basically I want a way to make an array that simulates the proton and neutron structure of an atom. Atoms have both protons and neutrons in the nucleus, and I want a way to reproduce this using blender.

As you can see in this picture, the Uranium-235 atom has a heck-of-a-lot of protons and neutrons (ignore the one neutron shooting off due to nuclear fission). I do not need the disorganization of the actual protons and neutrons, I just want an array to simulate the structural look.

Thanks.

• – cegaton May 1 '15 at 22:02
• – cegaton May 1 '15 at 22:08

Add a sphere, copy it, scale it down in edit mode

Select the big sphere, go to the Object panel, under Duplication select Verts

Select the small sphere, hold shift, then select the big sphere. Hit CTRL+P and set the paren to Vertex

Result should look like that

You can now go select the big sphere again and go to edit mode, select all vertices. Use the "Randomize" option, I used a setting of 0.06.

You can use the Object info -> Random input together with a Math node to give them different colors.

This isn't an accurate representation of an atom I guess, but you said it's about simplicity and the visualisation aspect.

P.S.: If you are worried about the top / bottom of the result, as there are more spheres, you can try another type of sphere for the big sphere, e.g. the icosphere, that has an even distribution of vertices.

You are looking for a spherical array, but maybe you would settle for a set of points which are spread out evenly over the surface of a sphere?

If you are comfortable with the Math, you can easily script a vertex based object which can act as a 'donor of vectors/3d points' to place instances of smaller spheres (Neutrons, Protons).

import bpy
import random
import math

def fibonacci_sphere(samples, rseed):
# http://stackoverflow.com/a/26127012/1243487
rnd = 1.
random.seed(rseed)
rnd = random.random() * samples

points = []
offset = 2./samples
increment = math.pi * (3. - math.sqrt(5.));

for i in range(samples):
y = ((i * offset) - 1) + (offset / 2);
r = math.sqrt(1 - pow(y,2))

phi = ((i + rnd) % samples) * increment

x = math.cos(phi) * r
z = math.sin(phi) * r

points.append([x,y,z])

return points

verts = fibonacci_sphere(120, rseed=20)

mesh = bpy.data.meshes.new("mesh_name")
mesh.from_pydata(vertices=verts, edges=[], faces=[])
mesh.update()

obj = bpy.data.objects.new("obj_name", mesh)

scene = bpy.context.scene


This bit of code when Run from the Text Editor, will produce a sphere of points based on fibonacci. This might give you the approximation.

### Mapping the spheres onto the points.

1. The script creates a points mesh named "obj_name" and adds it to the scene, in the object properties set duplication type to Verts,
2. Create the Neutron/Proton representative sphere on the same origin as the points mesh, (I like to use a Object->Surface->NURBS Sphere)
3. Set the Parent of the sphere to the points mesh.

This way you get a kind of Donor / Recipient relationship between the points mesh and the Neutron/Proton spheres.

When you render, the original NURBS sphere at the origin won't be visible, in contrast to when you are viewing in the 3d viewport, you'll see it all the time.

### Sverchok

The Sverchok addon can be be used for this kind of visualization: https://blender.stackexchange.com/a/28792/47 . It's a Free and open source modular, node based geometry system built on Blender's custom Python Nodes API.

The same script as above exists inside Sverchok as a scripted node, meaning you can adjust a slider to increase or decrease the number of points (samples), and set a different Seed value (random starting point) without having to delete the object and run the script again. Then you connect other nodes to operate on the scale of the vectors it produces, then you can pick vectors by some logic gate and separate them into 2 different meshes, then assign the different spheres to represent Neutrons and Protons.

Within the space of 2 minutes I made this: (full disclosure I'm a contributor to Sverchok.. but with practice anyone can blaze through it)

The sphere of points is indexed, and i'm splitting them up by by the boolean result of index % 2. if that's 1 it goes into one mesh, else it goes into the other. The image above is just drawing openGL, there's no scene mesh yet.

We have nodes that do output meshes to the scene, called Bmesh Nodes

rather than every second vector, you can generate a random number for each vector and if it's larger than some value (between 0.0, 1.0), it goes into one mesh, else the other.

Here's the blend for that.

With a small modification you can even push the vectors away from the origin in a pulsating way.. drag the seed value or animate it

Though I imagine it behaves very differently, twisting and contorting..

A very simple approach (admittedly less powerful than zeffii's). You can apply three array modifiers to an object, e.g. a sphere, and then play around with offset until you have a nice 3D grid of spheres. Then you can apply the modifiers and start removing spheres until you have a somewhat nucleus-like object. Its fairly straight forward, my steps were:

1. Create 3D grid with array modifiers. I found that these settings with a default sphere gave a nice grid. When you are happy with how the spheres tessellate you apply the modifiers (the order of application is important, start from the top).

1. Center the object origin. Go into edit mode (tab), and select all vertices (A). Center the curser in the geometry (S -> U), go back into object mode (tab), and set the geometry center at the 3D curser (shift + ctrl + alt -> T).

2. Create the nucleus border. Create a new sphere (shift + A -> M -> U) at the center of the 3D grid. Scale the sphere up until its sides become visible just outside of the 3D grid.

3. Remove spheres in the grid, outside of the nucleus border. Select the grid and go into edit mode. Start deleting spheres that are not contained by your new sphere object. A nice hotkey to use here is ctrl + L, which selects all connected vertices of any selected vertices, such that you can easily select a connected component. Your end result should look something like this, on the left without the nucleus border removed, and on the right, your final result.

You might want to play around with which protons/neutrons you wan't to keep in your nucleus, in order to make it appear realistic (if we are allowed to use this term). For very large nuclei this can look great, but depending on your computer's processing power, you might end up having trouble manipulating the geometry in edit mode because of the enormous number of vertices.

SO If you're looking for something simple go for this method, otherwise I suggest you spend a moment longer and try to implement zeffii's.

• I think I prefer your method, or maybe a containment forcefield. – zeffii May 2 '15 at 8:16
• @zeffii thanks! not much to it, but with a containment forcefield, it's definitely a bit more interesting, didn't think of that one. – Ulf Aslak May 2 '15 at 9:03