DAMASK_EICMD/python/damask/solver/abaqus.py

28 lines
1.1 KiB
Python
Raw Normal View History

2014-06-24 21:02:42 +05:30
# -*- coding: UTF-8 no BOM -*-
from .solver import Solver
2016-07-15 20:23:57 +05:30
import damask
2019-02-15 18:53:16 +05:30
import subprocess
2014-06-24 21:02:42 +05:30
class Abaqus(Solver):
2018-07-06 16:42:16 +05:30
def __init__(self,version=''): # example version string: 2017
2014-06-24 21:02:42 +05:30
self.solver='Abaqus'
if version =='':
2016-07-14 19:42:05 +05:30
version = damask.Environment().options['ABAQUS_VERSION']
2014-06-24 21:02:42 +05:30
else:
self.version = version
def return_run_command(self,model):
env=damask.Environment()
try:
cmd='abq'+self.version
subprocess.check_output([cmd,'information=release'])
2014-06-25 14:02:33 +05:30
except OSError: # link to abqXXX not existing
2014-06-24 21:02:42 +05:30
cmd='abaqus'
2014-06-25 14:02:33 +05:30
process = subprocess.Popen(['abaqus','information=release'],stdout = subprocess.PIPE,stderr = subprocess.PIPE)
detectedVersion = process.stdout.readlines()[1].split()[1].decode('utf-8')
2014-06-25 14:02:33 +05:30
if self.version != detectedVersion:
raise Exception('found Abaqus version {}, but requested {}'.format(detectedVersion,self.version))
return '{} -job {} -user {}/src/DAMASK_abaqus interactive'.format(cmd,model,env.rootDir())