# -*- coding: utf-8 -*-
"""
Created on Wed Dec 3 15:05:43 2014
@author: Matti Ropo
@author: Henrik Levämäki
"""
from __future__ import print_function
import sys
import os
import datetime
import re
import pyemto.common.common as common
[docs]class Kfcd:
"""Handles the information and writing of kfcd file.
:param jobname: (Default value = None)
:type jobname:
:param latname: (Default value = None)
:type latname:
:param latpath: (Default value = None)
:type latpath:
:param msgl: (Default value = None)
:type msgl:
:param nprn: (Default value = None)
:type nprn:
:param lmaxs: (Default value = None)
:type lmaxs:
:param nth: (Default value = None)
:type nth:
:param kfcd_nfi: (Default value = None)
:type kfcd_nfi:
:param fpot: (Default value = None)
:type fpot:
:param ovcor: (Default value = None)
:type ovcor:
:param ubg: (Default value = None)
:type ubg:
:param DIR001: (Default value = None)
:type DIR001:
:param DIR002: (Default value = None)
:type DIR002:
:param DIR003: (Default value = None)
:type DIR003:
:param DIR004: (Default value = None)
:type DIR004:
:param DIR006: (Default value = None)
:type DIR006:
:param sws: (Default value = None)
:type sws:
:returns: None
:rtype: None
"""
def __init__(self, jobname=None, latname=None, latpath=None, msgl=None, nprn=None,
lmaxs=None, nth=None, kfcd_nfi=None, fpot=None, ovcor=None,
ubg=None, DIR001=None, DIR002=None, DIR003=None, DIR004=None,
DIR006=None, sws=None, CQNA=None, KFCD_file_type=None):
self.jobname = jobname
self.latname = latname
self.latpath = latpath
self.msgl = msgl
self.nprn = nprn
self.lmaxs = lmaxs
self.nth = nth
self.kfcd_nfi = kfcd_nfi
self.fpot = fpot
self.ovcor = ovcor
self.ubg = ubg
self.DIR001 = DIR001
self.DIR002 = DIR002
self.DIR003 = DIR003
self.DIR004 = DIR004
self.DIR006 = DIR006
self.CQNA = CQNA
self.KFCD_file_type = KFCD_file_type
if KFCD_file_type is None:
self.KFCD_file_type = 'kfcd'
[docs] def output(self):
"""Outputs KFCD input file as a formatted string.
Outputs EMTO5.8 KFCD input file
:returns: Formatted string
:rtype: str
"""
now = datetime.datetime.now()
#line = "KFCD MSGL..= %1i " % (self.msgl) +\
line = "KFCD MSGL..= {0:1}".format(self.msgl) + " CQNA= {0} ".format(self.CQNA) +\
str(now.day) + "." + str(now.month) + "." + str(now.year) + "\n"
line = line + "JOBNAM...=" + self.jobname + "\n"
line = line + "STRNAM...=" + self.latname + "\n"
line = line + "DIR001=" + self.DIR001 + "\n"
line = line + "DIR002=" + self.DIR002 + "\n"
line = line + "DIR003=" + self.DIR003 + "\n"
line = line + "DIR004=" + self.DIR004 + "\n"
line = line + "DIR006=" + self.DIR006 + "\n"
line = line + "Lmaxs.=%3i NTH..=%3i NFI..=%3i FPOT..= %1s"\
% (self.lmaxs, self.nth, self.kfcd_nfi, self.fpot) + "\n"
line = line + "OVCOR.= %1s UBG..= %1s NPRN.= %1s"\
% (self.ovcor, self.ubg, self.nprn) + "\n"
return line
[docs] def set_values(self, key, value):
"""Changes values of the class variables.
:param key: name of the variable
:type key: str
:param value: value of the variable
:type value: str, int or float
:returns: None
:rtype: None
"""
if not hasattr(self, key):
print('WARNING: Kfcd() class has no attribute \'{0}\''.format(key))
return
# Lattice name or path has changed => we have to update the FOR and DIR
# information
elif key == 'latpath':
setattr(self, key, value)
self.DIR001 = self.latpath + '/kstr/'
self.DIR001 = common.cleanup_path(self.DIR001)
self.DIR003 = self.latpath + '/shape/'
self.DIR003 = common.cleanup_path(self.DIR003)
self.DIR004 = self.latpath + '/bmdl/'
self.DIR004 = common.cleanup_path(self.DIR004)
else:
setattr(self, key, value)
return