DipoleSurface

Provides a unified interface to working with dipole surfaces. Currently basically no fancier than a regular surface (although with convenient loading functions), but dipole-specific stuff could come

 

__init__(self, mu_x, mu_y, mu_z): 
  • mu_x: Surface

    X-component of dipole moment

  • mu_y: Surface

    Y-component of dipole moment

  • mu_z: Surface

    Z-component of dipole moment

 

get_log_values(log_file, keys=('StandardCartesianCoordinates', 'DipoleMoments')): 

 

from_log_file(log_file, coord_transf, keys=('StandardCartesianCoordinates', 'DipoleMoments'), tol=0.001, **opts): 

Loads dipoles from a Gaussian log file and builds a dipole surface by interpolating. Obviously this only really works if we have a subset of “scan” coordinates, so at this stage the user is obligated to furnish a function that’ll take a set of Cartesian coordinates and convert them to “scan” coordinates. Coordinerds can be helpful with this, as it provides a convenient syntax for Cartesian <-> ZMatrix conversions

  • log_file: str

    a Gaussian log file to pull from

  • :returns: _

 

get_fchk_values(fchk_file): 

 

from_fchk_file(fchk_file, **opts): 

Loads dipoles from a Gaussian formatted checkpoint file and builds a dipole surface via a linear approximation

  • fchk_file: Any

    a Gaussian fchk file to pull from

  • log_file: str
  • :returns: _

 

__call__(self, gridpoints, **opts): 

Explicitly overrides the Surface-level evaluation because we know the Taylor surface needs us to flatten our gridpoints

  • gridpoints: Any
  • opts: Any
  • :returns: _

Examples

Before we can run our examples we should get a bit of setup out of the way. Since these examples were harvested from the unit tests not all pieces will be necessary for all situations.

All tests are wrapped in a test class

class DataTests(TestCase):
    maxDiff = None

FChkFileDipoleSurface

    def test_FChkFileDipoleSurface(self):
        fchk = TestManager.test_data("HOD_freq.fchk")
        surf = DipoleSurface.from_fchk_file(fchk)
        surf_center = surf.surfs[0].base.data['center']
        self.assertIsInstance(surf_center, np.ndarray)
        self.assertTrue(
            np.allclose(surf(surf_center) - np.array([s.base.data['ref'] for s in surf.surfs]), 0.)
        )
        self.assertEquals(surf([[0, 0, 0], [1, 0, 0], [0, 1, 0]]).shape, (1, 3))
        self.assertEquals(surf([
            [[0, 0, 0], [1, 0, 0], [0, 1, 0]],
            [[0, 0, 0], [1, 0, 0], [0, 1, 0]]
        ]).shape, (2, 3))

LogFileDipoleSurface

    def test_LogFileDipoleSurface(self):
        log = TestManager.test_data("water_OH_scan.log")
        conv = lambda x: cartesian_to_zmatrix(
            x, ordering=[[0, -1, -1, -1], [1, 0, -1, -1], [2, 0, 1, -1]]
        ).coords[:, 0, 0]
        surf = DipoleSurface.from_log_file(log, conv)
        dips = surf(np.arange(.5, 2, .1))
        self.assertEquals(dips.shape, ((2-.5)/.1, 3))

Feedback

Examples

Templates

Documentation