column[tensor] = table.label_index(tensor)

  if errors != []:
    damask.util.croak(errors)
    table.close(dismiss = True)
    continue

# ------------------------------------------ assemble header --------------------------------------

  table.info_append(scriptID + '\t' + ' '.join(sys.argv[1:]))
  table.labels_append(['%i_Cauchy'%(i+1) for i in xrange(6)])                                       # extend ASCII header with new labels
  table.head_write()

# ------------------------------------------ process data ------------------------------------------
  outputAlive = True
  while outputAlive and table.data_read():                                                          # read next data line of ASCII table
    F = np.array(map(float,table.data[column[options.defgrad]:column[options.defgrad]+9]),'d').reshape(3,3)
    P = np.array(map(float,table.data[column[options.stress ]:column[options.stress ]+9]),'d').reshape(3,3)
    Cauchy = list(1.0/np.linalg.det(F)*np.dot(P,F.T).reshape(9))                                    # [Cauchy] = (1/det(F)) * [P].[F_transpose]
    # 11(0) 12(1) 13(2); 21(3) 22(4) 23(5); 31(6) 32(7) 33(8) to 11(0) 22(1) 33(2) 12(3) 23(4) 31(5)
    Cauchy = [Cauchy[0], Cauchy[4], Cauchy[8], 0.5*(Cauchy[1] + Cauchy[3]), 0.5*(Cauchy[5]+Cauchy[7]), 0.5*(Cauchy[2]+Cauchy[6])]
    if options.compress:
        precision = outputPrecision['cr_stress']
        Cauchy = [ delPlusZero(format( i, precision[2]%(precision[0]-1))  ) for i in Cauchy]
    table.data_append(Cauchy)                                                                       # [Cauchy] = (1/det(F)) * [P].[F_transpose]
    outputAlive = table.data_write()                                                                # output processed line

# ------------------------------------------ output finalization -----------------------------------

  table.close()                                                                                     # close input ASCII table (works for stdin)
Exemple #2
0
      for theStretch in stretches:
        stretch[theStretch] = np.where(abs(stretch[theStretch]) < 1e-12, 0, stretch[theStretch])    # kill nasty noisy data
        (D,V) = np.linalg.eig(stretch[theStretch])                                                  # eigen decomposition (of symmetric matrix)
        neg = np.where(D < 0.0)                                                                     # find negative eigenvalues ...
        D[neg]   *= -1.                                                                             # ... flip value ...
        V[:,neg] *= -1.                                                                             # ... and vector
        for i,eigval in enumerate(D):
          if np.dot(V[:,i],V[:,(i+1)%3]) != 0.0:                                                    # check each vector for orthogonality
              V[:,(i+1)%3] = np.cross(V[:,(i+2)%3],V[:,i])                                          # correct next vector
              V[:,(i+1)%3] /= np.sqrt(np.dot(V[:,(i+1)%3],V[:,(i+1)%3].conj()))                     # and renormalize (hyperphobic?)
        for theStrain in strains:
          d = operator(theStretch,theStrain,D)                                                      # operate on eigenvalues of U or V
          eps = list( (np.dot(V,np.dot(np.diag(d),V.T)).real).reshape(9) )                          # build tensor back from eigenvalue/vector basis

          # 11(0) 12(1) 13(2); 21(3) 22(4) 23(5); 31(6) 32(7) 33(8) to 11(0) 22(1) 33(2) 12(3) 23(4) 31(5)
          eps = [eps[0], eps[4], eps[8], 0.5*(eps[1] + eps[3]), 0.5*(eps[5]+eps[7]), 0.5*(eps[2]+eps[6])]
          if options.compress:
              precision = outputPrecision['cr_deform']
              eps = [ delPlusZero(format( i, precision[2]%(precision[0]-1))  ) for i in eps]

          table.data_append(eps)

# ------------------------------------------ output result -----------------------------------------

    outputAlive = table.data_write()                                                                # output processed line

# ------------------------------------------ output finalization -----------------------------------  

  table.close()                                                                                     # close ASCII tables
Exemple #3
0
    while outputAlive and table.data_read(
    ):  # read next data line of ASCII table
        F = np.array(
            map(
                float,
                table.data[column[options.defgrad]:column[options.defgrad] +
                           9]), 'd').reshape(3, 3)
        P = np.array(
            map(float,
                table.data[column[options.stress]:column[options.stress] + 9]),
            'd').reshape(3, 3)
        Cauchy = list(1.0 / np.linalg.det(F) * np.dot(
            P, F.T).reshape(9))  # [Cauchy] = (1/det(F)) * [P].[F_transpose]
        # 11(0) 12(1) 13(2); 21(3) 22(4) 23(5); 31(6) 32(7) 33(8) to 11(0) 22(1) 33(2) 12(3) 23(4) 31(5)
        Cauchy = [
            Cauchy[0], Cauchy[4], Cauchy[8], 0.5 * (Cauchy[1] + Cauchy[3]),
            0.5 * (Cauchy[5] + Cauchy[7]), 0.5 * (Cauchy[2] + Cauchy[6])
        ]
        if options.compress:
            precision = outputPrecision['cr_stress']
            Cauchy = [
                delPlusZero(format(i, precision[2] % (precision[0] - 1)))
                for i in Cauchy
            ]
        table.data_append(Cauchy)  # [Cauchy] = (1/det(F)) * [P].[F_transpose]
        outputAlive = table.data_write()  # output processed line

# ------------------------------------------ output finalization -----------------------------------

    table.close()  # close input ASCII table (works for stdin)
Exemple #4
0
        table.labels_append('Mises({})'.format(what))                                               # extend ASCII header with new labels

  if remarks != []: damask.util.croak(remarks)
  if errors  != []:
    damask.util.croak(errors)
    table.close(dismiss = True)
    continue

# ------------------------------------------ assemble header --------------------------------------

  table.info_append(scriptID + '\t' + ' '.join(sys.argv[1:]))
  table.head_write()

# ------------------------------------------ process data ------------------------------------------

  outputAlive = True
  while outputAlive and table.data_read():                                                          # read next data line of ASCII table
    for type, data in items.iteritems():
      for column in data['column']:
        precision = outputPrecision[{'stress':'cr_stress', 'strain':'cr_deform'}[type.lower()]]
 
        mises_val = Mises(type,np.array(table.data[column:column+data['dim']],'d').reshape(data['shape']))
        table.data_append( delPlusZero( format(mises_val, precision[2]%(precision[0]-1) ) ) )
        #table.data_append(Mises(type,
                                #np.array(table.data[column:column+data['dim']],'d').reshape(data['shape'])))
    outputAlive = table.data_write()                                                                # output processed line

# ------------------------------------------ output finalization -----------------------------------

  table.close()                                                                                     # close input ASCII table (works for stdin)
Exemple #5
0
      pos = 0
      for chunk in newby:
        mappedResult[pos:pos+chunk['len']] = mapIncremental(chunk['label'],options.func,
                                                            N,mappedResult[pos:pos+chunk['len']],chunk['content'])
        if options.compress:
          result2str = False
          for var in allVariables:
              if chunk['label'] in var:
                  writePrecision = outputPrecision[var[-1]]
                  if writePrecision[1] != 0:
                      # needs to scale the unit, such as transform Pa to MPa for stress
                      mappedResult[pos:pos+chunk['len']] = [i*writePrecision[1] for i in mappedResult[pos:pos+chunk['len']]]

                  for ip in xrange(chunk['len']):
                      mappedResult[pos+ip] = delPlusZero(format(mappedResult[pos+ip], writePrecision[2]%writePrecision[0])) if len(str(mappedResult[pos+ip])) > \
                      writePrecision[0]+2 else str(mappedResult[pos+ip])
                  result2str = True

          if not result2str:
              mappedResult[pos:pos+chunk['len']] = map(str, mappedResult[pos:pos+chunk['len']])
        else:
            mappedResult[pos:pos+chunk['len']] = map(str, mappedResult[pos:pos+chunk['len']])

        pos += chunk['len']

      N += 1

    # --- write data row to file ---

    if not headerWritten:
Exemple #6
0
    # ------------------------------------------ process data ------------------------------------------

    outputAlive = True
    while outputAlive and table.data_read(
    ):  # read next data line of ASCII table
        for type, data in items.iteritems():
            for column in data['column']:
                vec6 = table.data[column:column + data['dim']]
                tensor33 = [
                    vec6[0], vec6[3], vec6[5], vec6[3], vec6[1], vec6[4],
                    vec6[5], vec6[4], vec6[2]
                ]
                mises_val = Mises(
                    type,
                    np.array(tensor33, 'd').reshape(data['shape']))
                if options.compress:
                    precision = outputPrecision[{
                        'stress': 'cr_stress',
                        'strain': 'cr_deform'
                    }[type.lower()]]
                    mises_val = delPlusZero(
                        format(mises_val, precision[2] % (precision[0])))
                table.data_append(mises_val)

        outputAlive = table.data_write()  # output processed line

# ------------------------------------------ output finalization -----------------------------------

    table.close()  # close input ASCII table (works for stdin)