Let me know if this works for you. I had to use a variable "eps" to correct for divide by 0 and acos() range errors.
import math
import numpy as np
import odbAccess
import os
import shutil
import time
import datetime
from abaqus import *
from abaqusConstants import *
from...