# ======================================================================
# matscipy - Python materials science tools
# https://github.com/libAtoms/matscipy
#
# Copyright (2014) Lars Pastewka, Karlsruhe Institute of Technology
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
# ======================================================================

import numpy as np

from ase.lattice.cubic import Diamond

###

def diamond_110_110(el, a0, n, crack_surface=[1,1,0],
                    crack_front=[1,-1,0],
                    fixx=0.5, fixz=1.0, vac=5.0):
    nx, ny, nz  = n
    third_dir   = np.cross(crack_surface, crack_front)
    a = Diamond(el,
            latticeconstant  = a0,
            size             = [ nx,ny,nz ], 
            directions       = [ third_dir, crack_surface, crack_front ]
            )
    sx, sy, sz = a.get_cell().diagonal()
    a.translate([ sx/(8*nx), sy/(4*ny), sz/(4*nz) ])
    a.set_scaled_positions(a.get_scaled_positions())

    lx  = fixx*sx/nx
    lz  = fixz*sz/nz
    r   = a.get_positions()
    g   = np.where(
        np.logical_or(
            np.logical_or(
                np.logical_or(
                    r[:, 0] < lx, r[:, 0] > sx-lx),
                r[:, 2] < lz),
            r[:, 2] > sz-lz),
        np.zeros(len(a), dtype=int),
        np.ones(len(a), dtype=int))
    a.set_array('groups', g)

    a.set_cell([sx+2*vac, sy, sz+2*vac])
    a.translate([ vac, 0.0, vac ])
    a.set_pbc([False, True, False])

    return a

###

def diamond_110_001(el, a0, n, crack_surface=[1,1,0], crack_front=[0,0,1],
                    fixx=1.0, fixz=1.0, vac=5.0):
    nx, ny, nz = n
    third_dir = np.cross(crack_surface, crack_front)
    directions = [ third_dir, crack_front, crack_surface ]
    if np.linalg.det(directions) < 0:
        third_dir = -third_dir
    directions = [ third_dir, crack_front, crack_surface ]
    a = Diamond(el, latticeconstant = a0, size = [ nx,ny,nz ], 
                directions = directions)
    sx, sy, sz = a.get_cell().diagonal()
    a.translate([ sx/(4*nx), sy/(8*ny), sz/(4*nz) ])
    a.set_scaled_positions(a.get_scaled_positions())

    lx  = fixx*sx/nx
    lz  = fixz*sz/nz
    r   = a.get_positions()
    g   = np.where(
        np.logical_or(
            np.logical_or(
                np.logical_or(
                    r[:, 0] < lx, r[:, 0] > sx-lx),
                r[:, 2] < lz),
            r[:, 2] > sz-lz),
        np.zeros(len(a), dtype=int),
        np.ones(len(a), dtype=int))
    a.set_array('groups', g)

    a.set_cell([sx+2*vac, sy, sz+2*vac])
    a.translate([ vac, 0.0, vac ])
    a.set_pbc([False, True, False])

    return a

@@ -1113,21 +1113,25 @@
     
-fix
+skin_
 x=0.5, 
-fix
+skin_
 z=1.
@@ -1556,35 +1556,37 @@
 s())%0A%0A    lx  = 
-fix
+skin_
 x*sx/nx%0A    lz  
@@ -1579,35 +1579,37 @@
 sx/nx%0A    lz  = 
-fix
+skin_
 z*sz/nz%0A    r   
@@ -2176,21 +2176,25 @@
     
-fix
+skin_
 x=1.0, 
-fix
+skin_
 z=1.
@@ -2728,19 +2728,21 @@
   lx  = 
-fix
+skin_
 x*sx/nx%0A
@@ -2755,11 +2755,13 @@
   = 
-fix
+skin_
 z*sz

Renamed fixx, fixz to skin_x, skin-Z