Skip to content

Commit

Permalink
final files
Browse files Browse the repository at this point in the history
  • Loading branch information
mandd committed May 26, 2023
1 parent ab83307 commit b065ddb
Show file tree
Hide file tree
Showing 21 changed files with 45 additions and 20,194 deletions.
26 changes: 11 additions & 15 deletions ravenframework/CodeInterfaceClasses/MELCOR/melcorTools.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,19 @@
Last update on October 14, 2022
@authors:
Matteo D'Onorio (University of Rome La Sapienza)
Paolo Balestra (University of Rome La Sapienza)
Paolo Balestra (University of Rome La Sapienza)
"""
from struct import unpack
import numpy as np
from collections import Counter

# ===============================================================================
def MCRBin(fileDir, VarSrch):
"""
This method is called to collect the variables to be used in the postprocess
@ In, fileDirectory, string, the file directory. This is the directory of the MELCOR plot file
@ In, variableSearch, list, list of variables to be collected
@ Out, Data, tuple (numpy.ndarray,numpy.ndarray,numpy.ndarray), this contains the extracted data for each declare variable
"""
from struct import unpack
import numpy as np
from collections import Counter
HdrList = []
BlkLenBef = []
BlkLenAft = []
Expand All @@ -26,7 +26,6 @@ def MCRBin(fileDir, VarSrch):
with open(fileDir, 'rb') as bf:
while True:
BlkLenBefSlave = bf.read(4)
print(BlkLenBefSlave)
if not BlkLenBefSlave:
break
BlkLenBef.append(unpack('I', BlkLenBefSlave)[0])
Expand Down Expand Up @@ -87,31 +86,28 @@ def MCRBin(fileDir, VarSrch):
VarUdmFull=['sec','','','']+VarUdmFull
for Nam in VarSrch:
VarSrchPos.append(VarNameFull.index(Nam.strip()))
VarUdmFull=[VarUdmFull[i] for i in VarSrchPos]
VarUdmFull=[VarUdmFull[i] for i in VarSrchPos]
SwapPosVarSrch=sorted(range(len(VarSrchPos)), key=lambda k: VarSrchPos[k])
SwapPosVarSrch=sorted(range(len(SwapPosVarSrch)), key=lambda k: SwapPosVarSrch[k])
VarSrchPos.sort()
VarSrchPos.append(VarName[1]+4)
HdrList.append([])
VarSrchPos.append(VarName[1]+4)
HdrList.append([])
elif HdrList[cntr - 1] == '.TR/':
DataPos.append(bf.tell())
bf.seek(BlkLenBef[cntr], 1)
HdrList.append([])
else:
HdrList.append([])
BlkLenAft.append(unpack('I', bf.read(4))[0])

cntr +=1

data = np.empty([len(DataPos), len(VarSrch)+1])*np.nan


data=np.empty([len(DataPos), len(VarSrch)+1])*np.nan
with open(fileDir, 'rb') as bf:
for i,Pos in enumerate(DataPos):
bf.seek(Pos, 0)
for j in range(len(VarSrchPos)-1):
data[i,j]=unpack('f', bf.read(4))[0]
bf.seek((VarSrchPos[j+1]-VarSrchPos[j])*4-4, 1)

data=data[:,SwapPosVarSrch]

return data[:,0],data[:,1:],VarUdmFull[1:]
14 changes: 6 additions & 8 deletions tests/framework/CodeInterfaceTests/MelcorInterface/test.i
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ MEL_OUTPUTFILE 'OUTPUT_MELCOR.out'
!EXTDIAGFILE 'EXTDIAG.TXT'
!
!*************************************************
!'test_1'
! 'test_1' *
!*************************************************
!
!
Expand Down Expand Up @@ -55,21 +55,19 @@ TF_TAB 2 !n x y
2 100.0 1.
!
CF_INPUT !
CF_ID 'ZERO' 01 EQUALS !
CF_ID 'ZERO' 1 EQUALS !
CF_SAI 1.0 0.0 0.0 ! CFSCAL CFADCN CFVALR (INITIAL VALUE)
CF_ARG 1 ! NARG CHARG ARSCAL ARADCN
1 EXEC-TIME 0.0 0.0
!
CF_INPUT !
CF_ID 'Tes CF' 02 EQUALS !
CF_ID 'Test_CF' 2 EQUALS !
CF_SAI 1.0 0.0 0.0 ! CFSCAL CFADCN CFVALR (INITIAL VALUE)
CF_ARG 1 ! NARG CHARG ARSCAL ARADCN
1 EXEC-TIME 2.0 1.0
!
!
CVH_INPUT
!
!
! cvname icvnum
CV_ID 'IN' 1
! icvthr ipfsw icvact
Expand Down Expand Up @@ -152,10 +150,10 @@ Program MELCOR
!* Block: MEX (Exec) data ****************************
EXEC_INPUT
EXEC_TITLE test_1 ! Title of the calculation
EXEC_TEND 10.0E+03 !* ! End of calculation time
EXEC_TEND 10.0E+02 !* ! End of calculation time
EXEC_TIME 2 !*NUMBER TIME DTMAX DTMIN DTEDT DTPLT DTRST DCRST
1 0.00 0.1000E+00 0.10000E-06 2.50000E+03 1.00000E+01 1.00000E+03 0.10000000E+11
2 1.50000E+02 0.2000E+00 0.10000E-09 2.50000E+03 1.00000E+01 1.0000E+03 0.10000000E+11
1 0.00 0.5000E+00 0.10000E-06 2.50000E+03 1.00000E+01 1.00000E+03 0.10000000E+11
2 1.50000E+03 0.5000E+00 0.10000E-09 2.50000E+03 1.00000E+01 1.0000E+03 0.10000000E+11

EXEC_CPULEFT 1000. ! cpu sec left at end of calculation
EXEC_CPULIM 4000000. ! Maximum number of CPU seconds allowed for this execution
Expand Down
Loading

0 comments on commit b065ddb

Please sign in to comment.