當前位置: 首頁>>代碼示例>>Python>>正文


Python BlockFactory.get_parameters方法代碼示例

本文整理匯總了Python中WaveBlocksND.BlockFactory.get_parameters方法的典型用法代碼示例。如果您正苦於以下問題:Python BlockFactory.get_parameters方法的具體用法?Python BlockFactory.get_parameters怎麽用?Python BlockFactory.get_parameters使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在WaveBlocksND.BlockFactory的用法示例。


在下文中一共展示了BlockFactory.get_parameters方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: transform_inhawp_to_eigen

# 需要導入模塊: from WaveBlocksND import BlockFactory [as 別名]
# 或者: from WaveBlocksND.BlockFactory import get_parameters [as 別名]
def transform_inhawp_to_eigen(iomin, iomout, blockidin=0, blockidout=0):
    """Compute the transformation to the eigenbasis for a wavepacket.
    Save the result back to a file.

    :param iomin: An :py:class:`IOManager: instance providing the simulation data.
    :param iomout: An :py:class:`IOManager: instance for saving the transformed data.
    :param blockidin: The data block from which the values are read. Default is `0`.
    :param blockidout: The data block to which the values are written. Default is `0`.
    """
    parameters = iomin.load_parameters()

    # Number of time steps we saved
    timesteps = iomin.load_inhomogwavepacket_timegrid(blockid=blockidin)
    nrtimesteps = timesteps.shape[0]

    # The potential used
    Potential = BlockFactory().create_potential(parameters)

    # Basis transformator
    BT = BasisTransformationHAWP(Potential)

    # Initialize a Hagedorn wavepacket with the data
    descr = iomin.load_inhomogwavepacket_description(blockid=blockidin)
    HAWP = BlockFactory().create_wavepacket(descr)

    iomout.add_inhomogwavepacket(descr, timeslots=nrtimesteps, blockid=blockidout)
    iomout.save_inhomogwavepacket_description(HAWP.get_description(), blockid=blockidout)

    BT.set_matrix_builder(HAWP.get_quadrature())

    # Basis shapes
    BS_descr = iomin.load_inhomogwavepacket_basisshapes()
    BS = {}
    for ahash, descr in BS_descr.iteritems():
        BS[ahash] = BlockFactory().create_basis_shape(descr)

    # Iterate over all timesteps
    for i, step in enumerate(timesteps):
        print(" Compute eigentransform at timestep # " + str(step))

        # Retrieve simulation data
        params = iomin.load_inhomogwavepacket_parameters(timestep=step, blockid=blockidin)
        hashes, coeffs = iomin.load_inhomogwavepacket_coefficients(timestep=step, get_hashes=True, blockid=blockidin)

        # Configure the wavepacket
        HAWP.set_parameters(params)
        HAWP.set_basis_shape([ BS[int(ha)] for ha in hashes ])
        HAWP.set_coefficients(coeffs)

        # Transform to the eigenbasis.
        BT.transform_to_eigen(HAWP)

        # Save the transformed packet
        # Pi
        iomout.save_inhomogwavepacket_parameters(HAWP.get_parameters(), timestep=step, blockid=blockidout)
        # Basis shapes (in case they changed!)
        for shape in HAWP.get_basis_shape():
            iomout.save_inhomogwavepacket_basisshapes(shape, blockid=blockidout)
        # Coefficients
        iomout.save_inhomogwavepacket_coefficients(HAWP.get_coefficients(), HAWP.get_basis_shape(), timestep=step, blockid=blockidout)
開發者ID:VasileGradinaru,項目名稱:WaveBlocksND,代碼行數:62,代碼來源:EigentransformHagedornWavepacket.py


注:本文中的WaveBlocksND.BlockFactory.get_parameters方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。