def He3Density(pressure, temperature): density = ctypes.c_double(0.0) idid = ctypes.c_int(0) P = ctypes.c_double(pressure) T = ctypes.c_double(temperature) he3pak.DFPTdll(density, idid, P, T) return density.value
''' Usage: In relation to the HEPAK xla file, which uses: =HeCalc(Index, Phase, Input1, Value1, Input2, Value2, Unit) In the example below, Input1, Value1, Input2, Value2 correspond to JIN1,VALU1,JIN2,VALU2 Unit corresponds to NUNITS Index is j Phase is i. It is kind of returned by IDID. If single phase, then i=0 should be used. If dual phase, then i=1 has the saturated liquid and i=2 has the vapour. ''' # inputs NPRCIS=ctypes.c_int(3) NUNITS=ctypes.c_int(1) JOUT=ctypes.c_int(11111) JIN1=ctypes.c_int(2) VALU1=ctypes.c_double(1.6) JIN2=ctypes.c_int(14) VALU2=ctypes.c_double(0) # returns IDID=ctypes.c_int() PROP=((ctypes.c_double*42)*3)() calc(IDID,PROP,JOUT,JIN1,VALU1,JIN2,VALU2,NPRCIS,NUNITS) #for i in range(3): #for j in range(42):
self._call_demo_routine_( ctypes.byref(param_char), param_int, ctypes.byref(param_type_test) ) # +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ # MAKE A CALL # +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ if __name__ == '__main__': # Initialize some test parameters sample_param_char = ctypes.c_char(7) sample_param_int = ctypes.c_int(42) # Initialize a test structure sample_type_test = type_test_struct() # Fill test structure with data sample_type_test.el_char = ctypes.c_char(5) sample_type_test.el_int8t = ctypes.c_int8(17) sample_type_test.el_int16t = ctypes.c_int16(25874) sample_type_test.el_float = ctypes.c_float(2.4) sample_type_test.el_double = ctypes.c_double(8.598e31) el_int8t_4 = [1, 2, 3, 4] sample_type_test.el_int8t_4 = (ctypes.c_int8 * len(el_int8t_4))(*el_int8t_4) el_int8t_2x3 = [[1, 2], [3, 4], [5, 6]] sample_type_test.el_int8t_2x3 = (ctypes.c_int8 * len(el_int8t_2x3[0]) * len(el_int8t_2x3))(*(tuple(i) for i in el_int8t_2x3)) # Initialize caller samples = sample_class()