def hasMtnumIninp(self, inpfile, matnum): mh = McnpinpHandler() cellcards = mh.readCellCards(inpfile) matincellcard = [] for line in cellcards: lists = line.strip().split() matincellcard.append(lists[1]) for mat in matnum: if mat not in matincellcard: mh.errorMessage(' material number {:} do not exists!\n'.format(mat)) return False return True
def isTMPIdentical(self, filename, workpath=None): inpfile = filename tmpdic = {} if workpath: inpfile = os.path.join(workpath, filename) mh = McnpinpHandler() cellcards = mh.readCellCards(inpfile) for line in cellcards: lists = line.strip().split() mat = lists[1] if mat not in tmpdic.keys(): tmpdic[mat] = [] for ii, eachstr in enumerate(lists): if 'tmp' in eachstr or 'TMP' in eachstr: tmp = lists[ii][4:] tmpdic[mat].append(tmp) for key, tmps in tmpdic.items(): if len(set(tmps)) > 1: mh.errorMessage('The TMP card of material {:} is inconsistent!\n'.format(key)) return False return True
def isTemEqMtnum(self, filename, workpath=None): inpfile = filename if workpath: inpfile = os.path.join(workpath, filename) mh = McnpinpHandler() cellcards = mh.readCellCards(inpfile) tmpnum = 0 matnum = 0 for cellcard in cellcards: if '$' in cellcard: cellcard = cellcard[:cellcard.find('$')] if cellcard.find('tmp')>0 or cellcard.find('TMP')>0: tmpnum += 1 if cellcard.strip().split()[1] != '0': matnum += 1 if tmpnum == matnum: print ('matnum is ', matnum, ' tmpnum is ', tmpnum) return True else: print ('matnum is ', matnum, ' tmpnum is ', tmpnum) print ('The number of tmp and the number of material are not identical !') return False