ribbon.spiralshapes module#
Functions to construct shapes based on plane spirals.
- ribbon.spiralshapes.write_xyz(x, y, z, atom_symbol='C', filename='out.xyz', title='')[source]#
Writes atom positions to a XYZ file.
- Parameters:
- x, y, z1D array_like
x, y, and z coordinates of the atoms. All three must have the same length.
- atom_symbolstr
Atom symbol. If more than two characters, will be trucated to the first two characters.
- filenamepath_like
Name of output file (XYZ format) with extension ‘.xyz’.
- titlestr
A title string for the XYZ file.
- Returns:
- None
- ribbon.spiralshapes.extrude(xcoords, ycoords, zdist, dz)[source]#
Creates a sheet of monoatomic thickness by extruding a spiral and returns the positions of the atoms of the sheet.
- Parameters:
- xcoords, ycoords1D array_like
X & Y coordinates of the points on the planar curve.
- zdistfloat
Extrusion distance (along z-direction)
- dzfloat
Spacing along the z-direction
- Returns:
- X, Y, Ztuple of 1D ndarrays
Coordinates of the atoms of the sheet.
- ribbon.spiralshapes.double_spiral(spiral, L, ds=0.5, same=False, end=1, f=0.0)[source]#
Create a double spiral from a single spiral.
The two spirals may be joined at either of the two ends. In addition, before joining, a the curvature of fraction of the arclength of both spirals may be linearized (if f > 0). Linearization is done by replacing a length fL of the curve by a Cornu spiral, whose curvature varies linearly with arclength, such that there is no discontinuity in the curvature of the resulting double spiral.
- Parameters:
- spiralSpiralPolarBase | SpiralCartesianBase
A spiral object
- Lfloat
Arclength of spiral. The double spiral will have arclength 2L.
- dsfloat
Spacing along the arclength.
- samebool
Whether the spirals are on the same side or not.
- end{0, 1}
If 0, the
s=0end. If 1, thes=Lend.- ffloat
Fraction of the arclength L over which the curvature will be linearized.
- Returns:
- s_ds, kappa_ds, x_ds, y_dstuple of 1D ndarrays
The arclength coordinates (s_ds), curvatures (kappa_ds), x-coordinates (x_ds), and y-coordinates (y_ds) of the double spiral.
Warning
Linearization may not always be necessary, and in some cases may lead to significant changes in the derivative of the curvature along the arclength.
Depending on the parameters of the spiral and which end is chosen for joining, the double spiral may self-intersect.