示例#1
0
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
示例#2
0
    def groupSetVelRatio(self, ratio):
        """
        Set the velocity percentage of a group from 0.0 to 100.0%.

        :param ratio: The velocity percentage will be set.
        :type ratio: float
        :return: error code
        :rtype: int
        """
        ret = self.__GroupSetVelRatio__(self.id_, self.index_, c_double(ratio))
        if ret == SUCCESS:
            self.groupVel_.value = ratio
        else:
            print("Set group velocity failed!")
        return ret
diameter = 6.  # mm
Tstart = 4.  # K; Temperature of He3 at Inlet of first gaseous cooling part
Tbath = 1.4  # K
Tend2 = 1.5  # K; Temperature of He3 at Outlet of last liquid cooling part
if options.yes_boundary:
    Tboundary = (Tstart + Tbath) / 2
mdot = 0.5  # g/s
step = 0.01  # m
p0 = 25000.  # Pa

ell = 0.0  # m; starting position

d_m = diameter / 1000  # m
mdot_m = mdot / 1000  # kg/s

Tk = ctypes.c_double()
pres = ctypes.c_double(p0)
TIPsatdll(Tk, pres)
temperature = Tk.value

Tend = Tk.value  #K

Xprop = (ctypes.c_double * 40)()

elllist = []
Tlist = []
Blist = []

while Tstart > Tend:

    #Def rho
示例#4
0
    def __init__(self, dll_path=DLL_PATH):
        self.dll_ = WinDLL(dll_path)
        self.ini_path_ptr_ = c_char_p(" ".encode('utf-8'))
        self.id_ = c_int32(0)
        self.index_ = c_int32(0)
        self.type_ = c_int32(DEVICE_TYPE_SIMULATOR)
        self.devState_ = c_int32(0)
        self.groupState_ = c_int32(0)
        self.groupVel_ = c_double(0)
        self.numGroup_ = c_int32(0)
        self.numGroupAxis_ = c_int32(0)
        self.actPos_ = Pos_T()
        self.desPos_ = Pos_T()
        self.refBasePntArr_ = [Pos_T() for i in range(3)]
        self.refBaseCoordTrans_ = CoordTrans_T()
        self.offsetByte_ = c_uint32(0)
        self.sizeByte_ = c_uint32(2)     # total two bytes (16 bits)
        self.doValue_ = c_uint16(0)
        self.diValue_ = c_uint16(0)
        self.pnt_list = []              # a list to store poses as list of 12 joint
        # Provide ctypes function prototypes
        self.__GetLibVersion__ = self.dll_.NMC_GetLibVersion
        self.__GetLibVersion__.argtypes = [POINTER(c_int32), POINTER(c_int32), POINTER(c_int32), POINTER(c_int32)]
        self.__GetLibVersion__.restype = c_int32

        self.__DeviceOpenUp__ = self.dll_.NMC_DeviceOpenUp
        self.__DeviceOpenUp__.argtypes = [c_int32, c_int32, POINTER(c_int32)]
        self.__DeviceOpenUp__.restype = c_int32

        self.__DeviceShutdown__ = self.dll_.NMC_DeviceShutdown
        self.__DeviceShutdown__.argtypes = [c_int32]
        self.__DeviceShutdown__.restype = c_int32

        self.__DeviceGetState__ = self.dll_.NMC_DeviceGetState
        self.__DeviceGetState__.argtypes = [c_int32, POINTER(c_int32)]
        self.__DeviceGetState__.restype = c_int32

        self.__DeviceGetGroupCount__ = self.dll_.NMC_DeviceGetGroupCount
        self.__DeviceGetGroupCount__.argtypes = [c_int32, POINTER(c_int32)]
        self.__DeviceGetGroupCount__.restype = c_int32

        self.__DeviceGetGroupAxisCount__ = self.dll_.NMC_DeviceGetGroupAxisCount
        self.__DeviceGetGroupAxisCount__.argtypes = [c_int32, c_int32, POINTER(c_int32)]
        self.__DeviceGetGroupAxisCount__.restype = c_int32

        self.__SetIniPath__ = self.dll_.NMC_SetIniPath
        self.__SetIniPath__.argtypes = [POINTER(c_char)]
        self.__SetIniPath__.restype = c_int32
        if HAS_ZUGBRUECKE:
            self.__SetIniPath__.memsync = [
                    {
                        'p' : [0],
                        'n' : True
                        }
                    ]

        self.__WriteOutputMemory__ = self.dll_.NMC_WriteOutputMemory
        self.__WriteOutputMemory__.argtypes = [c_int32, c_uint32, c_uint32, POINTER(c_uint16)]
        self.__WriteOutputMemory__.restype = c_int32

        self.__ReadOutputMemory__ = self.dll_.NMC_ReadOutputMemory
        self.__ReadOutputMemory__.argtypes = [c_int32, c_uint32, c_uint32, POINTER(c_uint16)]
        self.__ReadOutputMemory__.restype = c_int32

        self.__ReadInputMemory__ = self.dll_.NMC_ReadInputMemory
        self.__ReadInputMemory__.argtypes = [c_int32, c_uint32, c_uint32, POINTER(c_uint16)]
        self.__ReadInputMemory__.restype = c_int32

        self.__GroupResetDriveAlmAll__  = self.dll_.NMC_GroupResetDriveAlmAll
        self.__GroupResetDriveAlmAll__.argtypes = [c_int32, c_int32]
        self.__GroupResetDriveAlmAll__.restype = c_int32

        self.__GroupGetState__ = self.dll_.NMC_GroupGetState
        self.__GroupGetState__.argtypes = [c_int32, c_int32, POINTER(c_int32)]
        self.__GroupGetState__.restype = c_int32

        self.__GroupResetState__ = self.dll_.NMC_GroupResetState
        self.__GroupResetState__.argtypes = [c_int32, c_int32]
        self.__GroupResetState__.restype = c_int32

        self.__GroupEnable__ = self.dll_.NMC_GroupEnable
        self.__GroupEnable__.argtypes = [c_int32, c_int32]
        self.__GroupEnable__.restype = c_int32

        self.__GroupDisable__ = self.dll_.NMC_GroupDisable
        self.__GroupDisable__.argtypes = [c_int32, c_int32]
        self.__GroupDisable__.restype = c_int32

        self.__GroupSetVelRatio__ = self.dll_.NMC_GroupSetVelRatio
        self.__GroupSetVelRatio__.argtypes = [c_int32, c_int32, c_double]
        self.__GroupSetVelRatio__.restype = c_int32

        self.__GroupGetVelRatio__ = self.dll_.NMC_GroupGetVelRatio
        self.__GroupGetVelRatio__.argtypes = [c_int32, c_int32, POINTER(c_double)]
        self.__GroupGetVelRatio__.restype = c_int32

        self.__GroupGetActualPosAcs__ = self.dll_.NMC_GroupGetActualPosAcs
        self.__GroupGetActualPosAcs__.argtypes = [c_int32, c_int32, POINTER(Pos_T)]
        self.__GroupGetActualPosAcs__.restype = c_int32

        self.__GroupGetActualPosPcs__ = self.dll_.NMC_GroupGetActualPosPcs
        self.__GroupGetActualPosPcs__.argtypes = [c_int32, c_int32, POINTER(Pos_T)]
        self.__GroupGetActualPosPcs__.restype = c_int32

        self.__GroupAxesHomeDrive__ = self.dll_.NMC_GroupAxesHomeDrive
        self.__GroupAxesHomeDrive__.argtypes = [c_int32, c_int32, c_int32]
        self.__GroupAxesHomeDrive__.restype = c_int32

        self.__GroupSetHomePos__ = self.dll_.NMC_GroupSetHomePos
        self.__GroupSetHomePos__.argtypes = [c_int32, c_int32, c_int32, POINTER(Pos_T)]
        self.__GroupSetHomePos__.restype = c_int32

        self.__GroupPtpAcsAll__ = self.dll_.NMC_GroupPtpAcsAll
        self.__GroupPtpAcsAll__.argtypes = [c_int32, c_int32, c_int32, POINTER(Pos_T)]
        self.__GroupPtpAcsAll__.restype = c_int32

        self.__GroupLine__ = self.dll_.NMC_GroupLine
        self.__GroupLine__.argtypes = [c_int32, c_int32, c_int32, POINTER(Pos_T), c_void_p]
        self.__GroupLine__.restype = c_int32

        self.__GroupHalt__ = self.dll_.NMC_GroupHalt
        self.__GroupHalt__.argtypes = [c_int32, c_int32]
        self.__GroupHalt__.restype = c_int32

        self.__Group3DShow__ = self.dll_.NMC_Group3DShow
        self.__Group3DShow__.argtypes = [c_int32, c_int32]
        self.__Group3DShow__.restype = c_int32

        self.__Group3DAlwaysTop__ = self.dll_.NMC_Group3DAlwaysTop
        self.__Group3DAlwaysTop__.argtypes = [c_int32, c_int32, c_bool]
        self.__Group3DAlwaysTop__.restype = c_int32

        self.__Group3DDrawPath__ = self.dll_.NMC_Group3DDrawPath
        self.__Group3DDrawPath__.argtypes = [c_int32, c_int32, c_bool]
        self.__Group3DDrawPath__.restype = c_int32

        self.__BaseCalib_1p__ = self.dll_.NMC_BaseCalib_1p
        self.__BaseCalib_1p__.argtypes = [POINTER(Pos_T), POINTER(CoordTrans_T)]
        self.__BaseCalib_1p__.restype = c_int32

        self.__BaseCalib_2p__ = self.dll_.NMC_BaseCalib_2p
        self.__BaseCalib_2p__.argtypes = [POINTER(Pos_T), POINTER(Pos_T), POINTER(CoordTrans_T)]
        self.__BaseCalib_2p__.restype = c_int32

        self.__BaseCalib_3p__ = self.dll_.NMC_BaseCalib_3p
        self.__BaseCalib_3p__.argtypes = [POINTER(Pos_T), POINTER(Pos_T), POINTER(Pos_T), POINTER(CoordTrans_T)]
        self.__BaseCalib_3p__.restype = c_int32

        # Get DLL version
        mj = c_int32(0)
        mn = c_int32(0)
        st = c_int32(0)
        bd = c_int32(0)
        self.version_ = self.getLibVersion(mj, mn, st, bd)
        print("Dynamics library version =", self.version_, "(", mj.value, ",", mn.value,
              ",", st.value, ",", bd.value, ")")
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):
        #print(i,j,PROP[i][j])


#
示例#6
0
def He3SaturatedProp(property, temperature):
    T = ctypes.c_double(temperature)
    XpropL = (ctypes.c_double * 40)()
    XpropV = (ctypes.c_double * 40)()
    he3pak.SatXFunTdll(XpropL, XpropV, T)
    return XpropL[property - 1], XpropV[property - 1]
示例#7
0
def He3Prop(property, density, temperature):
    D = ctypes.c_double(density)
    T = ctypes.c_double(temperature)
    Xprop = (ctypes.c_double * 40)()
    he3pak.Fundtdll(Xprop, D, T)
    return Xprop[property - 1]
示例#8
0
def He3SaturatedTemperature(pressure):
    P = ctypes.c_double(pressure)
    T = ctypes.c_double(0.)
    he3pak.TIPsatdll(T, P)
    return T.value
示例#9
0
# 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()

	# Call
	samples.complex_demo_routine(sample_param_char, sample_param_int, sample_type_test)

	# Print result
	print([0, 2, 6, 12], sample_type_test.el_int8t_4[:])
	print(
		[[1, 3], [3, 5], [7, 6]],