+ - 0:00:00
Notes for current slide
Notes for next slide

Solvation Models

Implementation challenges, lessons learnt, best practices

Marco Caricato

The University of Kansas

Roberto Di Remigio

UiT - The Arctic University of Norway

1 / 23

Software grows complex over time

"The complexity of software is an essential property, not an accidental one Fred Brooks."

  • We start with a simple idea and overtime software grows complex
  • It is inherent characteristic of software to change and grow over time
  • There is no silver bullet for managing complexity. However, there are some bad practices that we can avoid.

(Slide taken from Complexity in software development by Radovan Bast and Harsha Vathsavayi)

2 / 23

The front panel: many dependencies

(c) Joe Paradiso

(Slide taken from Complexity in software development by Radovan Bast and Harsha Vathsavayi)

3 / 23

The back side: global variables

(c) Joe Paradiso

(Slide taken from Complexity in software development by Radovan Bast and Harsha Vathsavayi)

4 / 23

Simple vs. easy

(Slide taken from Complexity in software development by Radovan Bast and Harsha Vathsavayi)

5 / 23

The tar pit

  • Over time software tends to become harder and harder to reason about
  • The code base easily becomes untidy ("I'll fix it later")
  • Small changes become harder to implement
  • Hacks and workarounds trump design
  • Bugs start appearing in unexpected places
  • More time is spent debugging than developing
  • Complexity strangles development because it does not scale well

(Slide taken from Complexity in software development by Radovan Bast and Harsha Vathsavayi)

6 / 23

Software Development Is Essential to Quantum Chemistry

  • Software architecture must allow fast development of new methods.
  • Computer implementations must be reproducible1
  • New modelling challenges require new (or improved) methods and new (or improved) software implementations.
  • Software cannot be rewritten from scratch every time, we need to have extensible architectures
  • Fast-paced development cycles can only occur within a clear software structure
  • Modularity. Delimit capabilities, concerns, results.
  • Reinventing the wheel is bad
  • Build small, well-documented software components
  • Reuse components in different contexts

1 Hatton, L.; Warr, G. arXiv [q-bio.QM], (2016)

7 / 23

Quantum/Classical Polarizable Multiscale Models1

  • Use quantum and classical physics together
    • quantum for chemically relevant subsystem
    • classical and polarizable for the environment

1 Senn, H. M.; Thiel, W. Angew. Chem. Int. Ed. (2009), 48, 1198
8 / 23
  • The idea of multiscale models is to focus on the chemically relevant part of the system and treat the environment approximately.

Quantum/Classical Polarizable Multiscale Models

  • Discrete and continuum are similar
  • Solution of a linear system of equations to obtain polarization Ap=Bs
  1. What should be the boundary between classical and quantum software?

    • What should the quantum module take care of?
    • How to ensure extensibility?
  2. Can we exploit the similarity?

    • What should the classical module take care of?
    • How should quantum and classical communicate?
  3. What is needed to layer different methods for the environment?

    • How should different classical layers communicate?
    • Variational formulations?
  4. Performance bottlenecks and how to overcome them.

9 / 23

Quantum Layer

  1. Integrals
    • Who drives the computation of integrals?
    • Interoperable formats for data transfer of large arrays?
  2. SCF procedure
    • Updates of the energy
    • Updates of the Fock matrix
  3. Response calculations
    • Formation of the perturbed solvent contributions
    • Iterative solution of the response equations
  4. Post-SCF methods:
    • Linear response solvation
    • State-specific solvation
  5. Geometric derivatives
    • Numerical vs. analytic approaches
    • What contributions are needed from the classical layer?
    • Can automatic differentiation be used?
10 / 23

Post-SCF Methods: Linear Response (LR) Solvation

  • Response methods, e.g. TDDFT, with LR solvation require transition amplitudes to evaluate a “transition” solvent response.
  • In terms of code interface, these methods have similar requirements as the SCF:
    1. Read-in trial vector(s) of transition amplitudes (= density in SCF)
    2. Build solvent contribution and contract on the fly (= contribution to Fock matrix in SCF)
    3. Return contracted array to be added to QM contribution (= add to Fock matrix in SCF)
11 / 23

Post-SCF Methods: State-Specific (SS) Solvation

  • In SS solvation, the solvent response is equilibrated with a state density different than that of the SCF (e.g., CC, excited state, etc.)
  • SS solvation requires an external iterative procedure for the solute-solvent equilibration that is not required in “in vacuo” calculations.
    1. Who handles the external iteration, the QM module or the solvent module?
    2. The SCF may or may not be part of the external iteration. Is the QM code modular enough to handle external iterations only on the post-SCF part?
12 / 23

Continuum layer

  1. Generating the cavity

    • Reading the geometry
    • Identifying functional groups
    • Discretization
    • Is there an interoperable format to transfer cavity information?
  2. Classical solver

    • Environment representations, i.e. Green’s functions
    • Operator representations, i.e. collocation vs Galerkin vs domain decomposition
    • Linear system solver
  3. Geometric derivatives

    • What contributions are needed from the QM layer?
    • Can automatic differentiation be used?
13 / 23

Recommendations

14 / 23

A Checklist of Sorts for Application Programming Interfaces

In computer programming, an application programming interface (API) is a set of subroutine definitions, protocols, and tools for building software and applications.

Encapsulation

  • Hide internals by language or by convention
  • Interface exposed in a separate file
  • Expose the what, hide the how

Development history

  • Decouple the development history
  • Each unit should have its own Git history/repository

Source: Wikipedia Application programming interface

15 / 23

A Checklist of Sorts for Application Programming Interfaces, contd.

Documentation

  • Separate the what it can do from how is it implemented
  • Documented application programming interface (API)
  • Versioned API (semantic or sentimental or romantic versioning)

Testing

  • You don't want to find a bug in the Alps
  • Sharpens interfaces
  • Exposes coupling and cohesion

Building and deploying

  • Prerequisite for testable on its own
  • Suitable distribution mechanisms
16 / 23

Continuous refinement

  • Several drafts are written before submitting a paper
  • While developing software, continuous refinement is necessary

Divide and conquer

  • Split the code up
  • Construct your program from parts:
    • functions
    • modules
    • packages (Python) or libraries (C or or C++ or Fortran)
17 / 23

Functions, functions, functions

  • Build your code from functions
  • Break your code down to more functions
    • if you have too many levels of indentation
    • if a function gets too long
    • if a function does more than one thing
    • if you find it hard to name a function
  • A function that performs a single operation is simpler to understand, test, and reuse
  • A function that does not fit on one screen is too long
18 / 23

What about I/O?

  • Keep I/O on the outside and connected
  • Always read/write on the outside and pass data
  • Do not read/write deep down inside the code
  • Keep the inside of your code pure/stateless
  • Move all the state to the outside of your code
  • Keep the stateful outside shell thin

19 / 23

C interface for libraries

  • English is to humans what C is to programs
  • C is the common language
  • Basically any language can talk to a C interface
  • Create a C interface for your code
  • Better than Fortran interface (the latter imposes compilation order and introduces compiler dependence)

Core language

  • Core language can be any language that can export a C API
  • For single-core high-performance use C or C++ or Fortran
  • With an eccentric language you risk to reduce the number of contributors

Communicate through memory or through files?

  • Through memory is more general than through files
20 / 23

Import and export

  • Import only the functionality that you need
  • Import only where you need it
  • Export as little functionality as possible

Naming things

  • Use meaningful names
  • Indent
  • Use standard naming conventions
  • Python: use PEP8
  • Write comments in English
getlnm() vs getlastname()
21 / 23

Simplicity and clarity before elegance before efficiency

Avoid premature optimization

  • Do not optimize
  • If you have to optimize, optimize later
  • If you have to optimize, measure, do not guess

Simple is better than complex

22 / 23

Thanks for your attention!

Slideshow created using remark and served using cicero

Slides available on GitHub

Browse slides at http://tinyurl.com/continuum-talking-points

23 / 23

Software grows complex over time

"The complexity of software is an essential property, not an accidental one Fred Brooks."

  • We start with a simple idea and overtime software grows complex
  • It is inherent characteristic of software to change and grow over time
  • There is no silver bullet for managing complexity. However, there are some bad practices that we can avoid.

(Slide taken from Complexity in software development by Radovan Bast and Harsha Vathsavayi)

2 / 23
Paused

Help

Keyboard shortcuts

, , Pg Up, k Go to previous slide
, , Pg Dn, Space, j Go to next slide
Home Go to first slide
End Go to last slide
b / m / f Toggle blackout / mirrored / fullscreen mode
c Clone slideshow
p Toggle presenter mode
t Restart the presentation timer
?, h Toggle this help
Esc Back to slideshow