API reference
Generated from the public API sources themselves
(src/api/trc_api.F90, src/api/trc_capi.F90) by
sphinx-fortran-domain’s
FORD-backed lexer, so this page and the source cannot drift apart silently.
src/generated/ (the per-class integral kernels) is never parsed here –
see AGENTS.md: it is generator output, not something anyone reads as API.
trc_api – the Fortran API
trc_api is a thin facade: it uses and re-exports the public names of
three lower-layer modules (trc_basis_types, trc_device_binding,
trc_integrals) so that a Fortran caller needs only use trc_api. Because
every type and procedure it exposes is defined in one of those other
modules, not in trc_api.F90 itself, the autodoc view below is sparse: it
shows the module’s own header comment and nothing else, since the domain
only has FORD-level doc comments to show for entities declared in the file
it parses. The module’s own header comment (src/api/trc_api.F90, lines
1-45) explains the facade and its design in prose; the public names it
re-exports are listed there too.
trc_api (module)
The consumer-facing API: a device-resident basis object and batched drivers.
WHAT THIS IS FOR
Everything below the kernels is per-class !$acc routine seq code that
computes ONE shell block. That is the right shape for a generator and the
wrong shape for a caller. This module is the boundary: a caller hands over a
basis once, the data goes to the device once and stays there, and each
driver is a single do concurrent over shell pairs.
SHAPE OF THE INTERFACE
The basis is accepted in libcint’s atm/bas/env layout, because that is
what mqc already has – it carries a libcint backend, so no caller-side
conversion is needed to try this. It is converted ONCE into a
structure-of-arrays container that the kernels can read coalesced, rather
than being walked in that packed integer form on the device.
type(trc_basis_t) :: b
call b%from_libcint(atm, natm, bas, nshell, env)
call b%to_device()
call trc_1e(b, smat, tmat, vmat) ! nao x nao each
call b%release()
WHY ONE CALL FOR S, T AND V
They share every shell-pair quantity – zeta, P, the Gaussian product prefactor – and a caller forming a core Hamiltonian wants all three. Asking for them separately would read the primitive data three times to save nothing.
NO ATOMICS HERE
Distinct shell pairs write disjoint blocks of the output matrices, so each thread owns its output outright. That is the one respect in which the one-electron drivers are simpler than the Fock build, which has to scatter into six overlapping blocks per quartet.
The API is a facade over three lower-layer modules, re-exported here so a
caller needs only use trc_api: trc_basis_types (core: the basis and the
pair list), trc_device_binding (core: one GPU per rank) and trc_integrals
(eri: the 1e, multipole, PCM and DF drivers and their LMAX ceilings).
Library code below the API layer uses those modules directly.
trc_capi – the C ABI (Fortran declaration)
trc_capi.F90 is where the bind(c) entry points actually live, each one
documented with a FORD !! block placed, per terco’s convention, as the
first lines of the procedure body (so it documents the procedure, not its
first argument). This is the module sphinx-fortran-domain’s FORD lexer
exercises most: hundreds of bind(c) functions, most with a doc comment.
trc_capi (module)
the C ABI
The Fortran API is the real one; this is a thin bind(c) skin over it so a
caller that is not Fortran can use the library. It owns no logic – every
entry point unpacks C types, calls the Fortran routine, and returns a status
code.
Variables
- TRC_OKinteger(kind=c_int), parameter, Default = 0
- TRC_ERR_NULLinteger(kind=c_int), parameter, Default = 1
- TRC_ERR_BADARGinteger(kind=c_int), parameter, Default = 2
- TRC_ERR_UNSUPPORTEDinteger(kind=c_int), parameter, Default = 3
- TRC_ERR_NOCONVinteger(kind=c_int), parameter, Default = 4
the SCF ran out of iterations
- TRC_ERR_STATEinteger(kind=c_int), parameter, Default = 5
called before what it needs was set
- TRC_GUESS_COREinteger(kind=c_int), parameter, Default = 0
One declaration, so one FORD block; each kind that needs more than its name has its own paragraph below.
TRC_GUESS_MINAO: the minimal-ANO density (trc_minao’s own trc_minao_build) projected into this run’s basis – no free-atom SCF, so nothing cached; refused for an element above Kr or a Cartesian basis with occupied d (trc_minao’s own checks). Always NEUTRAL atoms, as PySCF’s init_guess_by_minao: for an ion the guess carries the neutral electron count, unlike TRC_GUESS_SADQ, and the first Roothaan step fixes the count.
TRC_GUESS_PROJECTED: the density from THIS context’s own last orbitals (cx%bb%cmo, stored by any run with at least one iteration, not only a converged one), re-orthonormalised in the CURRENT geometry’s overlap (trc_scf_context’s
scf_context_project_density) – a warm start for a SEQUENCE of nearby geometries at the SAME molecule and basis (a geometry optimiser’s steps, or a finite-difference Hessian’s displacements) that is exact when the geometry has not moved at all and degrades gracefully as it does, unlike reusing the raw density unprojected. Refused (TRC_ERR_STATE) if no previous SCF at this nao has run yet, if it was run with fractional occupation (scf_context_project_densityonly builds integer occupations), or at a size/spin mismatch. See trc_run_scf’s own dispatch; test/standalone/bench_warmstart.F90 measured it against the plain density warm start at water/def2-SVP, steps 0.005-1.0 Bohr: the two warm starts needed the same iteration count at every step (HF 10/13/15, B3LYP 8/10/12). Appended, not inserted: 0-3 are what they have always been, so a caller built against the old header keeps working.- TRC_GUESS_GWHinteger(kind=c_int), parameter, Default = 1
One declaration, so one FORD block; each kind that needs more than its name has its own paragraph below.
TRC_GUESS_MINAO: the minimal-ANO density (trc_minao’s own trc_minao_build) projected into this run’s basis – no free-atom SCF, so nothing cached; refused for an element above Kr or a Cartesian basis with occupied d (trc_minao’s own checks). Always NEUTRAL atoms, as PySCF’s init_guess_by_minao: for an ion the guess carries the neutral electron count, unlike TRC_GUESS_SADQ, and the first Roothaan step fixes the count.
TRC_GUESS_PROJECTED: the density from THIS context’s own last orbitals (cx%bb%cmo, stored by any run with at least one iteration, not only a converged one), re-orthonormalised in the CURRENT geometry’s overlap (trc_scf_context’s
scf_context_project_density) – a warm start for a SEQUENCE of nearby geometries at the SAME molecule and basis (a geometry optimiser’s steps, or a finite-difference Hessian’s displacements) that is exact when the geometry has not moved at all and degrades gracefully as it does, unlike reusing the raw density unprojected. Refused (TRC_ERR_STATE) if no previous SCF at this nao has run yet, if it was run with fractional occupation (scf_context_project_densityonly builds integer occupations), or at a size/spin mismatch. See trc_run_scf’s own dispatch; test/standalone/bench_warmstart.F90 measured it against the plain density warm start at water/def2-SVP, steps 0.005-1.0 Bohr: the two warm starts needed the same iteration count at every step (HF 10/13/15, B3LYP 8/10/12). Appended, not inserted: 0-3 are what they have always been, so a caller built against the old header keeps working.- TRC_GUESS_SADinteger(kind=c_int), parameter, Default = 2
One declaration, so one FORD block; each kind that needs more than its name has its own paragraph below.
TRC_GUESS_MINAO: the minimal-ANO density (trc_minao’s own trc_minao_build) projected into this run’s basis – no free-atom SCF, so nothing cached; refused for an element above Kr or a Cartesian basis with occupied d (trc_minao’s own checks). Always NEUTRAL atoms, as PySCF’s init_guess_by_minao: for an ion the guess carries the neutral electron count, unlike TRC_GUESS_SADQ, and the first Roothaan step fixes the count.
TRC_GUESS_PROJECTED: the density from THIS context’s own last orbitals (cx%bb%cmo, stored by any run with at least one iteration, not only a converged one), re-orthonormalised in the CURRENT geometry’s overlap (trc_scf_context’s
scf_context_project_density) – a warm start for a SEQUENCE of nearby geometries at the SAME molecule and basis (a geometry optimiser’s steps, or a finite-difference Hessian’s displacements) that is exact when the geometry has not moved at all and degrades gracefully as it does, unlike reusing the raw density unprojected. Refused (TRC_ERR_STATE) if no previous SCF at this nao has run yet, if it was run with fractional occupation (scf_context_project_densityonly builds integer occupations), or at a size/spin mismatch. See trc_run_scf’s own dispatch; test/standalone/bench_warmstart.F90 measured it against the plain density warm start at water/def2-SVP, steps 0.005-1.0 Bohr: the two warm starts needed the same iteration count at every step (HF 10/13/15, B3LYP 8/10/12). Appended, not inserted: 0-3 are what they have always been, so a caller built against the old header keeps working.- TRC_GUESS_GIVENinteger(kind=c_int), parameter, Default = 3
One declaration, so one FORD block; each kind that needs more than its name has its own paragraph below.
TRC_GUESS_MINAO: the minimal-ANO density (trc_minao’s own trc_minao_build) projected into this run’s basis – no free-atom SCF, so nothing cached; refused for an element above Kr or a Cartesian basis with occupied d (trc_minao’s own checks). Always NEUTRAL atoms, as PySCF’s init_guess_by_minao: for an ion the guess carries the neutral electron count, unlike TRC_GUESS_SADQ, and the first Roothaan step fixes the count.
TRC_GUESS_PROJECTED: the density from THIS context’s own last orbitals (cx%bb%cmo, stored by any run with at least one iteration, not only a converged one), re-orthonormalised in the CURRENT geometry’s overlap (trc_scf_context’s
scf_context_project_density) – a warm start for a SEQUENCE of nearby geometries at the SAME molecule and basis (a geometry optimiser’s steps, or a finite-difference Hessian’s displacements) that is exact when the geometry has not moved at all and degrades gracefully as it does, unlike reusing the raw density unprojected. Refused (TRC_ERR_STATE) if no previous SCF at this nao has run yet, if it was run with fractional occupation (scf_context_project_densityonly builds integer occupations), or at a size/spin mismatch. See trc_run_scf’s own dispatch; test/standalone/bench_warmstart.F90 measured it against the plain density warm start at water/def2-SVP, steps 0.005-1.0 Bohr: the two warm starts needed the same iteration count at every step (HF 10/13/15, B3LYP 8/10/12). Appended, not inserted: 0-3 are what they have always been, so a caller built against the old header keeps working.- TRC_GUESS_SADQinteger(kind=c_int), parameter, Default = 4
One declaration, so one FORD block; each kind that needs more than its name has its own paragraph below.
TRC_GUESS_MINAO: the minimal-ANO density (trc_minao’s own trc_minao_build) projected into this run’s basis – no free-atom SCF, so nothing cached; refused for an element above Kr or a Cartesian basis with occupied d (trc_minao’s own checks). Always NEUTRAL atoms, as PySCF’s init_guess_by_minao: for an ion the guess carries the neutral electron count, unlike TRC_GUESS_SADQ, and the first Roothaan step fixes the count.
TRC_GUESS_PROJECTED: the density from THIS context’s own last orbitals (cx%bb%cmo, stored by any run with at least one iteration, not only a converged one), re-orthonormalised in the CURRENT geometry’s overlap (trc_scf_context’s
scf_context_project_density) – a warm start for a SEQUENCE of nearby geometries at the SAME molecule and basis (a geometry optimiser’s steps, or a finite-difference Hessian’s displacements) that is exact when the geometry has not moved at all and degrades gracefully as it does, unlike reusing the raw density unprojected. Refused (TRC_ERR_STATE) if no previous SCF at this nao has run yet, if it was run with fractional occupation (scf_context_project_densityonly builds integer occupations), or at a size/spin mismatch. See trc_run_scf’s own dispatch; test/standalone/bench_warmstart.F90 measured it against the plain density warm start at water/def2-SVP, steps 0.005-1.0 Bohr: the two warm starts needed the same iteration count at every step (HF 10/13/15, B3LYP 8/10/12). Appended, not inserted: 0-3 are what they have always been, so a caller built against the old header keeps working.- TRC_GUESS_SAPinteger(kind=c_int), parameter, Default = 5
One declaration, so one FORD block; each kind that needs more than its name has its own paragraph below.
TRC_GUESS_MINAO: the minimal-ANO density (trc_minao’s own trc_minao_build) projected into this run’s basis – no free-atom SCF, so nothing cached; refused for an element above Kr or a Cartesian basis with occupied d (trc_minao’s own checks). Always NEUTRAL atoms, as PySCF’s init_guess_by_minao: for an ion the guess carries the neutral electron count, unlike TRC_GUESS_SADQ, and the first Roothaan step fixes the count.
TRC_GUESS_PROJECTED: the density from THIS context’s own last orbitals (cx%bb%cmo, stored by any run with at least one iteration, not only a converged one), re-orthonormalised in the CURRENT geometry’s overlap (trc_scf_context’s
scf_context_project_density) – a warm start for a SEQUENCE of nearby geometries at the SAME molecule and basis (a geometry optimiser’s steps, or a finite-difference Hessian’s displacements) that is exact when the geometry has not moved at all and degrades gracefully as it does, unlike reusing the raw density unprojected. Refused (TRC_ERR_STATE) if no previous SCF at this nao has run yet, if it was run with fractional occupation (scf_context_project_densityonly builds integer occupations), or at a size/spin mismatch. See trc_run_scf’s own dispatch; test/standalone/bench_warmstart.F90 measured it against the plain density warm start at water/def2-SVP, steps 0.005-1.0 Bohr: the two warm starts needed the same iteration count at every step (HF 10/13/15, B3LYP 8/10/12). Appended, not inserted: 0-3 are what they have always been, so a caller built against the old header keeps working.- TRC_GUESS_PROJECTEDinteger(kind=c_int), parameter, Default = 6
One declaration, so one FORD block; each kind that needs more than its name has its own paragraph below.
TRC_GUESS_MINAO: the minimal-ANO density (trc_minao’s own trc_minao_build) projected into this run’s basis – no free-atom SCF, so nothing cached; refused for an element above Kr or a Cartesian basis with occupied d (trc_minao’s own checks). Always NEUTRAL atoms, as PySCF’s init_guess_by_minao: for an ion the guess carries the neutral electron count, unlike TRC_GUESS_SADQ, and the first Roothaan step fixes the count.
TRC_GUESS_PROJECTED: the density from THIS context’s own last orbitals (cx%bb%cmo, stored by any run with at least one iteration, not only a converged one), re-orthonormalised in the CURRENT geometry’s overlap (trc_scf_context’s
scf_context_project_density) – a warm start for a SEQUENCE of nearby geometries at the SAME molecule and basis (a geometry optimiser’s steps, or a finite-difference Hessian’s displacements) that is exact when the geometry has not moved at all and degrades gracefully as it does, unlike reusing the raw density unprojected. Refused (TRC_ERR_STATE) if no previous SCF at this nao has run yet, if it was run with fractional occupation (scf_context_project_densityonly builds integer occupations), or at a size/spin mismatch. See trc_run_scf’s own dispatch; test/standalone/bench_warmstart.F90 measured it against the plain density warm start at water/def2-SVP, steps 0.005-1.0 Bohr: the two warm starts needed the same iteration count at every step (HF 10/13/15, B3LYP 8/10/12). Appended, not inserted: 0-3 are what they have always been, so a caller built against the old header keeps working.- TRC_GUESS_MINAOinteger(kind=c_int), parameter, Default = 7
One declaration, so one FORD block; each kind that needs more than its name has its own paragraph below.
TRC_GUESS_MINAO: the minimal-ANO density (trc_minao’s own trc_minao_build) projected into this run’s basis – no free-atom SCF, so nothing cached; refused for an element above Kr or a Cartesian basis with occupied d (trc_minao’s own checks). Always NEUTRAL atoms, as PySCF’s init_guess_by_minao: for an ion the guess carries the neutral electron count, unlike TRC_GUESS_SADQ, and the first Roothaan step fixes the count.
TRC_GUESS_PROJECTED: the density from THIS context’s own last orbitals (cx%bb%cmo, stored by any run with at least one iteration, not only a converged one), re-orthonormalised in the CURRENT geometry’s overlap (trc_scf_context’s
scf_context_project_density) – a warm start for a SEQUENCE of nearby geometries at the SAME molecule and basis (a geometry optimiser’s steps, or a finite-difference Hessian’s displacements) that is exact when the geometry has not moved at all and degrades gracefully as it does, unlike reusing the raw density unprojected. Refused (TRC_ERR_STATE) if no previous SCF at this nao has run yet, if it was run with fractional occupation (scf_context_project_densityonly builds integer occupations), or at a size/spin mismatch. See trc_run_scf’s own dispatch; test/standalone/bench_warmstart.F90 measured it against the plain density warm start at water/def2-SVP, steps 0.005-1.0 Bohr: the two warm starts needed the same iteration count at every step (HF 10/13/15, B3LYP 8/10/12). Appended, not inserted: 0-3 are what they have always been, so a caller built against the old header keeps working.- TRC_AO_NORM_SHELLinteger(kind=c_int), parameter, Default = ao_norm_shell_
- TRC_AO_NORM_UNITinteger(kind=c_int), parameter, Default = ao_norm_unit_
- TRC_TIMING_NAME_MAXinteger(kind=c_int), parameter, Default = 64
a name buffer of this size always suffices.
- TRC_SCF_NEVENTSinteger(kind=c_int), parameter, Default = 10
trc_scf_events: the length of its
eventsarray.- TRC_NDIAGNOSTICSinteger(kind=c_int), parameter, Default = 8
trc_diagnostics: the length of its
valuesarray.- TRC_ABI_MAJORinteger(kind=c_int), parameter, Default = 1
- TRC_ABI_MINORinteger(kind=c_int), parameter, Default = 39
1.39: the analytic closed-shell RI-CCSD gradient: after a converged trc_run_rccsd without (T), trc_run_gradient differentiates the RI-CCSD total energy instead of refusing (an exact-ERI RHF reference, one rank); trc_check_rccsd_gradient, a new entry point, says before the SCF whether it will be refused. Additive. 1.38: trc_dipole_moment and trc_spin_square, new getters (the SCF determinant’s dipole and the unrestricted <S^2>). Additive. 1.37: trc_diagnostics, trc_nelec_grid, trc_scf_history_size, trc_scf_history and trc_scf_events, new entry points (the electron count the DFT grid integrated, the SCF’s per-iteration table and the convergence events the run decided), and trc_set_gradient_grid_response (Pulay-only Kohn-Sham ground-state gradient, as pyscf’s). Additive: the default gradient still differentiates the grid. 1.36: trc_run_tddft and trc_check_tddft accept a –df (density-fitted) reference, solved over the fit its SCF converged with; the TDDFT trc_run_gradient over –df is refused (not implemented yet), and trc_run_tddft after the fit was dropped (trc_set_jkfit_*) returns TRC_ERR_STATE. No signature change. 1.35: trc_run_tddft, trc_check_tddft and the TDDFT trc_run_gradient accept a spherical orbital basis (refused before). No signature change. 1.34: trc_run_gradient accepts –df with a spherical orbital and auxiliary basis (refused before). No signature change. 1.33: trc_tddft_window_open, a new entry point (the number of candidate Ritz pairs the TDDFT missed-root check left open); and the default of the missed-root iteration count is now 0 (it was 24 in 1.31 and 1.32), like the 1.20 change of the incremental Fock build: a fresh handle’s TDDFT roots can differ on a case that needed the iteration, and trc_set_tddft_missed_root_iterations(handle, 24) restores the previous behaviour; set it before trc_run_gradient or trc_opt_set_tddft follow a root by index (the CLI does for –grad and –opt). No signature or enum changes meaning. 1.32: trc_set_tddft_density_screen, a new entry point (the TDDFT matvec’s density screen, on by default). Additive. 1.31: trc_set_tddft_missed_root_iterations, a new entry point (the budget of the TDDFT solver’s candidate Ritz pairs after its probe). Additive. 1.30: closed-shell TDDFT/TDHF excitation energies and the excited-state gradient of one root: trc_set_tddft, trc_set_tddft_convergence, trc_run_tddft, trc_check_tddft, trc_tddft_nroots, trc_tddft_energies, trc_tddft_character, trc_tddft_target_root and trc_tddft_energy, new entry points; after a successful trc_run_tddft, trc_run_gradient differentiates the target root’s energy, and trc_run_hessian refuses. Additive. 1.29: trc_rccsd_energy_parts, a new entry point (the RI-CCSD correlation energy as its t1 t1 and t2 parts). Additive. 1.28: closed-shell RI-CCSD and RI-CCSD(T): trc_set_rccsd, trc_set_rccsd_convergence, trc_set_rccsd_algorithm, trc_run_rccsd, trc_rccsd_energy and trc_rccsd_dimensions, new entry points; trc_energy adds a converged result, and trc_run_gradient, trc_run_hessian and trc_run_polarizability refuse after one. Additive. 1.27: trc_set_gdm, a new entry point (geometric direct minimisation). Additive. 1.26: trc_set_scf_stabilise, a new entry point (maximum overlap occupation and a level shift kept on through DIIS). Additive. 1.25: trc_set_symmetry_skeleton (-1 the size rule, 0 off, 1 on) for the skeleton Fock build and four-centre gradient of a symmetric run (a new entry point, nothing else changes). 1.24: trc_timing and trc_timing_count, the stage times of the last run, one named value per call (new entry points, nothing else changes). 1.23: Abelian point-group symmetry for the SCF (additive; off by default, so no existing call or output frame changes). Requests: trc_set_symmetry(h, spec, tol) with “off” (the default; also “default”), “on”/”auto”, or a group (D2h and its subgroups); trc_set_irrep_nelec for fixed electrons per irrep; and trc_set_symmetry_report_frame. Getters: trc_symmetry_group, trc_symmetry_detected, trc_symmetry_residual, trc_symmetry_frame, trc_symmetry_report_frame, trc_symmetry_nirrep, trc_symmetry_irrep_name, trc_symmetry_irrep_dim, trc_mo_irreps and trc_geometry. “on”/”auto” reports the geometry, gradient, orbitals, density and the borrowed basis/ERI handles in the caller’s input frame, and runs the paths the symmetric SCF cannot take (DF, PCM, SOSCF, fractional occupations, a given or projected guess, several ranks, the Hessian, CPHF/CPKS, RI-MP2, Fukui indices, restarts, the optimiser) in C1. A named group, or fixed irrep occupations, reports the group’s standard frame and refuses those paths. Energies, orbital energies and Hirshfeld/CHELPG charges are invariant. A symmetric DFT run uses the grid of the caller’s axes, so its energy equals the symmetry-off one to second order (3e-12 Eh, B3LYP/cc-pVDZ water at the default grid). The skeleton builds change which integral quartets are launched, not the result: the gradient matches the C1 one to 3e-15..1e-14 relative. With accidental degeneracy, the per-orbital irrep labels can differ between the skeleton and full Fock paths (a permutation inside a degenerate level; the decomposition per irrep is the same), so a caller pinning occupations there should also fix the path with trc_set_symmetry_skeleton. 1.22: trc_set_ecp_json, a new entry point (an explicit effective core potential, overriding auto-attach from the orbital basis file’s own ecp_potentials). Additive. 1.21: trc_chelpg_charges, CHELPG charges fitted to the converged density’s electrostatic potential (a new entry point, nothing else changes). 1.20: the incremental Fock build is ON by default (trc_set_incremental was 0 by default before); trc_set_incremental(handle, 0) restores full builds every iteration, and density fitting never increments. The energies are unchanged (convergence is declared on a full build), so no signature or enum changes meaning. 1.19: trc_run_hessian accepts an RI-MP2/double-hybrid reference (one the RI-MP2 gradient supports) instead of refusing it, rerunning trc_run_rimp2 at every displacement; trc_check_rimp2_gradient asks, before any SCF, whether that gradient will be refused. Additive. (1.18 was never released on main.) 1.17: trc_run_gradient accepts a PCM reference; trc_run_hessian still refuses PCM.
- TRC_CONST_BOHR_TO_ANGSTROMinteger(kind=c_int), parameter, Default = 0
- TRC_CONST_HARTREE_TO_EVinteger(kind=c_int), parameter, Default = 1
- TRC_CONST_HARTREE_TO_KCALMOLinteger(kind=c_int), parameter, Default = 2
- TRC_CONST_AMU_TO_MEinteger(kind=c_int), parameter, Default = 3
- TRC_CONST_KB_SIinteger(kind=c_int), parameter, Default = 4
- TRC_CONST_NA_SIinteger(kind=c_int), parameter, Default = 5
Procedures
trc_basis_create (function)
-
function trc_basis_create(nshell, maxnp, l, nprim, exps, coefs, centres, natm, zatm, ratm, handle) -> status Build a basis from flat per-shell arrays.
centresis (3, nshell) andexps/coefsare (maxnp, nshell), both in Fortran order – which for C means column-major, i.e. the fastest index is the first. A C caller writing exps[shell][prim] has it transposed; the header comment says so rather than the library guessing.- Arguments:
- nshellinteger(kind=c_int), value
- maxnpinteger(kind=c_int), value
- linteger(kind=c_int), intent(in), dimension(nshell)
- npriminteger(kind=c_int), intent(in), dimension(nshell)
- expsreal(kind=c_double), (maxnp, nshell), intent(in), dimension(maxnp,nshell)
- coefsreal(kind=c_double), (maxnp, nshell), intent(in), dimension(maxnp,nshell)
- centresreal(kind=c_double), (3, nshell), intent(in), dimension(3,nshell)
- natminteger(kind=c_int), value
- zatmreal(kind=c_double), intent(in), dimension(natm)
- ratmreal(kind=c_double), (3, natm), intent(in), dimension(3,natm)
- handletype(c_ptr), intent(out)
- Returns:
- statusinteger(kind=c_int)
trc_basis_destroy (function)
-
function trc_basis_destroy(handle) -> status - Arguments:
- handletype(c_ptr), value
- Returns:
- statusinteger(kind=c_int)
trc_basis_nao (function)
-
function trc_basis_nao(handle, nao) -> status Number of atomic orbitals, so a caller can size its own output buffers.
- Arguments:
- handletype(c_ptr), value
- naointeger(kind=c_int), intent(out)
- Returns:
- statusinteger(kind=c_int)
trc_pairs_create (function)
-
function trc_pairs_create(basis, thresh, handle) -> status - Arguments:
- basistype(c_ptr), value
- threshreal(kind=c_double), value
- handletype(c_ptr), intent(out)
- Returns:
- statusinteger(kind=c_int)
trc_pairs_destroy (function)
-
function trc_pairs_destroy(handle) -> status - Arguments:
- handletype(c_ptr), value
- Returns:
- statusinteger(kind=c_int)
trc_pairs_count (function)
-
function trc_pairs_count(handle, npair) -> status - Arguments:
- handletype(c_ptr), value
- npairinteger(kind=c_int), intent(out)
- Returns:
- statusinteger(kind=c_int)
trc_compute_1e (function)
-
function trc_compute_1e(basis, pairs, smat, tmat, vmat) -> status S, T and V into caller-provided host buffers of nao*nao each.
The buffers are host memory and the library copies the result back. A device-pointer variant belongs here later for a caller already holding device memory; it is a second entry point, not a flag, because getting the two confused is a segfault rather than a wrong answer.
COVARIANT under
basis’s own ao_norm_kind (set through trc_set_ao_norm on a context that lent this handle via trc_context_basis; a raw trc_basis_create* handle is always TRC_AO_NORM_SHELL and this is then a no-op): S_out = N S N, same for T and V.- Arguments:
- basistype(c_ptr), value
- pairstype(c_ptr), value
- smatreal(kind=c_double), intent(out), dimension(*)
- tmatreal(kind=c_double), intent(out), dimension(*)
- vmatreal(kind=c_double), intent(out), dimension(*)
- Returns:
- statusinteger(kind=c_int)
trc_compute_df2c (function)
-
function trc_compute_df2c(aux, jmat) -> status - Arguments:
- auxtype(c_ptr), value
- jmatreal(kind=c_double), intent(out), dimension(*)
- Returns:
- statusinteger(kind=c_int)
trc_compute_df3c (function)
-
function trc_compute_df3c(basis, pairs, aux, tens) -> status - Arguments:
- basistype(c_ptr), value
- pairstype(c_ptr), value
- auxtype(c_ptr), value
- tensreal(kind=c_double), intent(out), dimension(*)
- Returns:
- statusinteger(kind=c_int)
trc_basis_create_libcint (function)
-
function trc_basis_create_libcint(atm, natm, bas, nshell, env, nenv, cartesian, handle) -> status Build a basis straight from libcint’s packed
atm/bas/env.THIS IS THE ONE A HOST CODE ACTUALLY WANTS. Anything with a libcint backend already holds these three arrays, so the alternative – unpacking them into per-shell arrays on the caller’s side and handing those to
trc_basis_create– is a conversion written twice, once here and once in every caller, with two chances to disagree about normalisation.CARTESIAN ONLY. libcint’s
bascarries the angular form in KAPPA_OF and terco has no spherical transform; a spherical basis silently reinterpreted as Cartesian gives wrong numbers rather than an error, so the caller is required to state it and is refused if it is not Cartesian.- Arguments:
- atminteger(kind=c_int), intent(in), dimension(*)
- natminteger(kind=c_int), value
- basinteger(kind=c_int), intent(in), dimension(*)
- nshellinteger(kind=c_int), value
- envreal(kind=c_double), intent(in), dimension(*)
- nenvinteger(kind=c_int), value
- cartesianinteger(kind=c_int), value
- handletype(c_ptr), intent(out)
- Returns:
- statusinteger(kind=c_int)
trc_basis_maxl (function)
-
function trc_basis_maxl(handle, maxl) -> status Highest angular momentum in the basis, so a caller can decide whether to use this library at all before it builds anything expensive. The four-centre kernels stop at d and the caller has to fall back rather than get a wrong answer.
- Arguments:
- handletype(c_ptr), value
- maxlinteger(kind=c_int), intent(out)
- Returns:
- statusinteger(kind=c_int)
trc_basis_shell_count (function)
-
function trc_basis_shell_count(handle, nshell) -> status Shell-data accessors.
A caller that already has its own basis-construction path (cyclone’s GAMESS-to-terco converter is the motivating one) can otherwise check only the AO count and the final energy against its own input; these four let it read back the shells THIS handle actually holds, so a conversion bug shows up as a wrong exponent or coefficient instead of only a wrong energy several steps later. They work on ANY basis handle – one built directly through trc_basis_create*/ trc_basis_create_libcint, or borrowed from a context through trc_context_basis – since both are the same
basis_box.Caller-provided buffers with a size query first, as trc_hessian/ trc_multipole_count already do: trc_basis_shell_count for NSHELL, then trc_basis_shell_info’s three NSHELL-long buffers, and trc_basis_shell_max_primitives for MAXNP to size trc_basis_shell_primitives’ two MAXNP*NSHELL buffers.
Number of shells, so a caller can size trc_basis_shell_info’s buffers. NOT split by decontraction (src/basis/trc_decontract.F90): that split lives inside trc_eri_t, built from a copy of this basis, and never touches the trc_basis_t this handle itself holds – this is always the basis as the caller (or trc_basis_from_json) built it.
- Arguments:
- handletype(c_ptr), value
- nshellinteger(kind=c_int), intent(out)
- Returns:
- statusinteger(kind=c_int)
trc_basis_shell_max_primitives (function)
-
function trc_basis_shell_max_primitives(handle, maxnp) -> status The second dimension trc_basis_shell_primitives’ exps/coefs buffers need (MAXNP*NSHELL each): the widest shell’s own primitive count, box%b%maxnp – the same bound trc_basis_create’s own
maxnpargument sets on the way in.- Arguments:
- handletype(c_ptr), value
- maxnpinteger(kind=c_int), intent(out)
- Returns:
- statusinteger(kind=c_int)
trc_basis_shell_info (function)
-
function trc_basis_shell_info(handle, atom, l, nprim) -> status Per shell, into three caller buffers of trc_basis_shell_count’s own NSHELL: ATOM is the 1-based index into trc_set_molecule’s own atom order (0 for a shell on no atom – a ghost/probe function; trc_api.F90’s
sh_at, matched by an exact coordinate hit against the atom list, same convention as every other 1-based index this library’s own Fortran side uses, e.g. trc_pairlist_t’sp_i/p_j). L is the angular momentum. NPRIM is the number of primitives actually retained:basis_builddrops a primitive whose coefficient is exactly zero (a dead column of a general- contraction table) once, when the basis is built, so this is the count trc_basis_shell_primitives below actually fills, which can be smaller than whatever the caller’s own input table listed for that shell.- Arguments:
- handletype(c_ptr), value
- atominteger(kind=c_int), intent(out), dimension(*)
- linteger(kind=c_int), intent(out), dimension(*)
- npriminteger(kind=c_int), intent(out), dimension(*)
- Returns:
- statusinteger(kind=c_int)
trc_basis_shell_primitives (function)
-
function trc_basis_shell_primitives(handle, exps, coefs) -> status Per-shell exponents and contraction coefficients, each (MAXNP, NSHELL) in Fortran column-major order – the SAME layout trc_basis_create’s own
exps/coefsarguments take – sized from trc_basis_shell_max_primitives and trc_basis_shell_count. A primitive past a shell’s own NPRIM (trc_basis_shell_info) is zero, exactly as a caller building a basis would pad a shorter shell in the same buffer.COEFFICIENTS:
basis_buildfolds libcint’s common_fac_sp into the STORED coefficient exactly once, on the way in (0.282094791773878143 for an s shell, 0.488602511902919921 for a p shell, 1 for l >= 2 – AGENTS.md’s “libcint’s common_fac_sp normalisation is applied exactly once, in basis construction”); this entry divides that one factor back out before handing the coefficient back, the same exact inverse test/trc_test_basis.F90’sunpack_basisalready relies on.WHAT THAT RECOVERS DEPENDS ON HOW THIS BASIS WAS BUILT. trc_basis_create/trc_basis_create_libcint call
builddirectly on the caller’s own coefficients with NOTHING else done to them, so for a handle built either way this is EXACTLY the caller’s own input, unchanged – the case cyclone’s GAMESS-to-terco conversion check (the motivating one) is in: it builds its own arrays and can compare them here bit for bit.trc_set_basis_json/trc_basis_from_json is NOT that case: trc_basis_json.F90’s own
read_elementrenormalises every shell’s coefficients to unit primitive AND unit contraction self-overlap (its ownnormalise, BSE’s/pyscf’s own convention) BEFORE handing them tobuild, which folds common_fac_sp in on top of THAT. Undoing only the common_fac_sp fold then does not reach the JSON file’s own literal number – a caller on that path sees terco’s fully renormalised coefficient instead (exponents are untouched either way, sincenormaliseonly rescalesc).- Arguments:
- handletype(c_ptr), value
- expsreal(kind=c_double), intent(out), dimension(*)
- coefsreal(kind=c_double), intent(out), dimension(*)
- Returns:
- statusinteger(kind=c_int)
trc_basis_is_spherical (function)
-
function trc_basis_is_spherical(handle, spherical) -> status Non-zero if this basis handle’s shells are spherical rather than Cartesian – box%b%spherical, set by trc_basis_from_json from a JSON basis’s own function_type, the same field trc_is_spherical reads off a context’s current basis (see that entry’s own comment for what it changes downstream). This is the basis- handle-level answer, for a caller that holds the handle directly rather than the context it came from – trc_context_basis hands out exactly that handle.
- Arguments:
- handletype(c_ptr), value
- sphericalinteger(kind=c_int), intent(out)
- Returns:
- statusinteger(kind=c_int)
trc_max_angular_momentum (function)
-
function trc_max_angular_momentum(eri_lmax, df_lmax, df_lmax_aux) -> status The angular-momentum ceilings THIS build was compiled for, so a host can check a basis against them instead of hard-coding them: the four-centre ERIs / SCF (TERCO_LMAX: 2 by default, 3 for f), and the density-fitting orbital and auxiliary bases (TERCO_DF_LMAX; the auxiliary one is one higher). Compare with trc_basis_maxl.
- Arguments:
- eri_lmaxinteger(kind=c_int), intent(out)
- df_lmaxinteger(kind=c_int), intent(out)
- df_lmax_auxinteger(kind=c_int), intent(out)
- Returns:
- statusinteger(kind=c_int)
trc_multipole_count (function)
-
function trc_multipole_count -> n Number of Cartesian multipole components, so a caller can size its buffer without hardcoding 39 and drifting when the operator order changes. Named for what it counts rather than
trc_nmult, which collides with the parameter of that name it returns.- Returns:
- ninteger(kind=c_int)
trc_compute_multipoles (function)
-
function trc_compute_multipoles(basis, pairs, origin, mmat) -> status Cartesian multipoles through the octupole about
origin, into a caller buffer of naonaotrc_nmult(). Component index is slowest, matching the Fortran (nao, nao, ncomp).COVARIANT under
basis’s own ao_norm_kind, one component at a time (see trc_compute_1e).- Arguments:
- basistype(c_ptr), value
- pairstype(c_ptr), value
- originreal(kind=c_double), intent(in), dimension(3)
- mmatreal(kind=c_double), intent(out), dimension(*)
- Returns:
- statusinteger(kind=c_int)
trc_eri_create (function)
-
function trc_eri_create(basis, thresh, handle) -> status The four-centre ERI object: Schwarz bounds, the binned pair list and the primitive-pair data, built once per geometry and reused by every Fock build. This is the expensive handle – creating one per SCF iteration would throw away the whole point of the container.
The four-centre engine for
basisat screening thresholdthresh. TRC_ERR_UNSUPPORTED, and no handle, when the basis has a shell above this build’s four-centre ceiling (trc_max_angular_momentum).- Arguments:
- basistype(c_ptr), value
- threshreal(kind=c_double), value
- handletype(c_ptr), intent(out)
- Returns:
- statusinteger(kind=c_int)
trc_eri_destroy (function)
-
function trc_eri_destroy(handle) -> status - Arguments:
- handletype(c_ptr), value
- Returns:
- statusinteger(kind=c_int)
capi_fock (function)
-
function capi_fock(eri, basis, dmat, gmat, jfac, kfac, dscreen, omega) -> status G = jJ - kK/2 for one density. Host buffers of nao*nao each.
jfacandkfacare passed by value and are NOT optional here: an optional argument has no C representation, and a caller that wants plain Hartree-Fock passes 1 and 1. Making them mandatory at the boundary also means a Kohn-Sham caller cannot forget them and silently get HF.CONTRAVARIANT in (dmat), COVARIANT out (gmat), under
basis’s own ao_norm_kind: this is GAMESS’s own main caller (its Fock/J/K build, run_Fockbuild’s role in hpcchem_driver.src), so it is wired rather than left at TRC_AO_NORM_SHELL like the entries the “not wired” list below still names. See fock_scale_in/fock_scale_out for why SHELL mode still costs nothing extra.- Arguments:
- eritype(c_ptr), value
- basistype(c_ptr), value
- dmatreal(kind=c_double), intent(in), dimension(*)
- gmatreal(kind=c_double), intent(out), dimension(*)
- jfacreal(kind=c_double), value
- kfacreal(kind=c_double), value
- dscreeninteger(kind=c_int), value
Nonzero to weight the Schwarz bound by the density (an SCF), zero for the plain Schwarz screen (a coupled-perturbed solve, whose trial vector the solver drives to zero – a density-keyed screen tightens as it does and the operator stops being a fixed linear map). An int rather than a logical: Fortran’s logical has no guaranteed C representation and c_bool is one byte against C’s four-byte int.
- omegareal(kind=c_double), value
Range-separation parameter, bohr^-1; zero is the ordinary Coulomb operator. See eri%fock.
- Returns:
- statusinteger(kind=c_int)
trc_fock_many (function)
-
function trc_fock_many(eri, basis, ndens, dmats, gmats, jfac, kfac, dscreen, omega) -> status N densities in one pass over the integrals.
dmatsandgmatsare (ndens, nao, nao) with the DENSITY INDEX FASTEST, which is the layout the kernel wants and not the one a C caller would guess. Phase 2 measured the alternative: with the density index slowest the N atomic updates for one (mu,nu) sit nao^2 apart and the batch stops paying past N = 4. The layout is part of the contract, so it is stated here rather than transposed silently.CONTRAVARIANT in, COVARIANT out, under
basis’s own ao_norm_kind – see capi_fock; the density-index-fastest layout means the UNIT-mode scaling here is its own small routines (fock_many_scale_in/out) rather than a reuse of fock_scale_in/out.- Arguments:
- eritype(c_ptr), value
- basistype(c_ptr), value
- ndensinteger(kind=c_int), value
- dmatsreal(kind=c_double), intent(in), dimension(*)
- gmatsreal(kind=c_double), intent(out), dimension(*)
- jfacreal(kind=c_double), value
- kfacreal(kind=c_double), value
- dscreeninteger(kind=c_int), value
- omegareal(kind=c_double), value
See capi_fock.
- Returns:
- statusinteger(kind=c_int)
trc_fock_nosym (function)
-
function trc_fock_nosym(eri, basis, dmat, gmat, dscreen) -> status The same build for a density that is NOT symmetric.
A separate entry point rather than a flag on
trc_fock, for the reason the Fortran side gives: the folded eight-fold digestion assumes D(mu,nu) = D(nu,mu), and a caller that passes an antisymmetric response density to the folded path gets a plausible wrong answer with no diagnostic. Two names cannot be confused by accident.CONTRAVARIANT in, COVARIANT out, exactly as capi_fock – the diagonal congruence ao_norm_scale_cov/fock_scale_in apply does not care whether
dmatis symmetric, so nothing here differs from the symmetric entry beyond which shared routines it reuses.- Arguments:
- eritype(c_ptr), value
- basistype(c_ptr), value
- dmatreal(kind=c_double), intent(in), dimension(*)
- gmatreal(kind=c_double), intent(out), dimension(*)
- dscreeninteger(kind=c_int), value
- Returns:
- statusinteger(kind=c_int)
capi_scf (function)
-
function capi_scf(basis, nalpha, nbeta, functional, grid_level, conv_energy, conv_density, max_iter, dguess, verbose, energy, e_xc, dmat, eps, niter) -> status The whole SCF: Hartree-Fock when
functionalis empty, Kohn-Sham otherwise; restricted when nalpha == nbeta, unrestricted otherwise, sonspinis 1 or 2 accordingly and the caller sizesdmatandepsas (nao, nao, nspin) and (nao, nspin).dguessmay be NULL for the core guess, or point at a (nao, nao, nspin) density – for a restricted case the total density, for an unrestricted one alpha then beta.functionalis a NUL-terminated C string; names are the ones trc_xc_functional knows.grid_levelis 0 to 9 in metalquicha’s sense.verbosenon-zero prints one line per iteration – energy, its change and the RMS density change – to standard output, since the iteration is otherwise invisible to a caller that only sees the final energy. A non-converged SCF returns TRC_ERR_NOCONV with the last energy and density filled in, so the caller can decide what that is worth.- Arguments:
- basistype(c_ptr), value
- nalphainteger(kind=c_int), value
- nbetainteger(kind=c_int), value
- functionalcharacter(kind=c_char, len=1), intent(in), dimension(*)
- grid_levelinteger(kind=c_int), value
- conv_energyreal(kind=c_double), value
- conv_densityreal(kind=c_double), value
- max_iterinteger(kind=c_int), value
- dguesstype(c_ptr), value
- verboseinteger(kind=c_int), value
- energyreal(kind=c_double), intent(out)
- e_xcreal(kind=c_double), intent(out)
- dmatreal(kind=c_double), intent(out), dimension(*)
- epsreal(kind=c_double), intent(out), dimension(*)
- niterinteger(kind=c_int), intent(out)
- Returns:
- statusinteger(kind=c_int)
capi_scf_mpi (function)
-
function capi_scf_mpi(fcomm, basis, nalpha, nbeta, functional, grid_level, conv_energy, conv_density, max_iter, dguess, verbose, energy, e_xc, dmat, eps, niter) -> status The same SCF run collectively by every rank of a communicator: the Fock build, the XC batches and the grid partition are split across the ranks and every rank returns the identical result.
fcommis the Fortran handle of the communicator (MPI_Comm_c2f from C, or the integer a Fortran caller holds), and every rank of it must call this together, because building terco’s own communicator from it duplicates it. Each rank binds its own device before anything else – the caller does not.ANY intra-communicator is accepted, not just MPI_COMM_WORLD: this is what lets GAMESS hand in DDI’s compute communicator, whose data-server ranks never call here at all, and what lets a fragment method hand in a per-fragment sub-communicator later. -1 is trc_scf on one rank in any build; in a build without MPI every other handle is also the single rank there is, because that is what pic-mpi’s serial backend’s comm_from_handle gives back.
- Arguments:
- fcomminteger(kind=c_int), value
- basistype(c_ptr), value
- nalphainteger(kind=c_int), value
- nbetainteger(kind=c_int), value
- functionalcharacter(kind=c_char, len=1), intent(in), dimension(*)
- grid_levelinteger(kind=c_int), value
- conv_energyreal(kind=c_double), value
- conv_densityreal(kind=c_double), value
- max_iterinteger(kind=c_int), value
- dguesstype(c_ptr), value
- verboseinteger(kind=c_int), value
- energyreal(kind=c_double), intent(out)
- e_xcreal(kind=c_double), intent(out)
- dmatreal(kind=c_double), intent(out), dimension(*)
- epsreal(kind=c_double), intent(out), dimension(*)
- niterinteger(kind=c_int), intent(out)
- Returns:
- statusinteger(kind=c_int)
capi_rimp2 (function)
-
function capi_rimp2(fcomm, basis, aux, nfrozen, aux_block, e_os, e_ss) -> status RI-MP2 on the orbitals of the last trc_scf (or trc_scf_mpi) on
basis, which must have been restricted.auxis the auxiliary basis, made like any other through trc_basis_create*;nfrozendoubly occupied orbitals are left out of the correlation;aux_blockbounds the depth of the three-index tensor held at once (0 for all of it). E_os and E_ss come back separately: MP2 is their sum, SCS and SOS are weights on them.fcommis ANY intra-communicator’s Fortran handle (see capi_scf_mpi); the occupied orbitals are split over its ranks and every rank gets the same numbers. -1 runs on one rank in any build.- Arguments:
- fcomminteger(kind=c_int), value
- basistype(c_ptr), value
- auxtype(c_ptr), value
- nfrozeninteger(kind=c_int), value
- aux_blockinteger(kind=c_int), value
- e_osreal(kind=c_double), intent(out)
- e_ssreal(kind=c_double), intent(out)
- Returns:
- statusinteger(kind=c_int)
trc_create (function)
-
function trc_create(handle) -> status - Arguments:
- handletype(c_ptr), intent(out)
- Returns:
- statusinteger(kind=c_int)
trc_destroy (function)
-
function trc_destroy(handle) -> status - Arguments:
- handletype(c_ptr), value
- Returns:
- statusinteger(kind=c_int)
trc_set_molecule (function)
-
function trc_set_molecule(handle, natm, z, xyz, charge, multiplicity) -> status Atoms in Bohr, nuclear charges as doubles, atom-major coordinates. Releases any effective core potential, and an orbital basis loaded with one attached (it is valence-only and was built for the reduced charges): load the basis again, which attaches the ECP for the new molecule. A basis loaded without an ECP is kept, and trc_run_scf refuses it (TRC_ERR_STATE) if it was built for other charges.
- Arguments:
- handletype(c_ptr), value
- natminteger(kind=c_int), value
- zreal(kind=c_double), intent(in), dimension(*)
- xyzreal(kind=c_double), intent(in), dimension(*)
- chargeinteger(kind=c_int), value
- multiplicityinteger(kind=c_int), value
- Returns:
- statusinteger(kind=c_int)
trc_set_charge (function)
-
function trc_set_charge(handle, charge, multiplicity) -> status Change the electron count on the SAME molecule, basis, auxiliary and jkfit bases – unlike trc_set_molecule, which always releases any –df fit, this keeps
cx%dfjk/cx%df_fit_ok: a fit depends on the geometry and the two bases (the metric, the three-centre tensor and its Cholesky factor – see trc_scf_df.F90’sdf_jk_setup’s own header, “meant to survive across more than one trc_scf_run on the same geometry”), never on the electron count, so an ionisation series on one handle (N, N+1, N-1, …) fits once and reuses it for every charge state instead of repeating the metric/Cholesky/3c/trsm for each.Same multiplicity check as trc_set_molecule (2S+1 >= 1); whether charge and multiplicity actually fit the electron count is trc_run_scf’s own check, exactly as it is reached through trc_set_molecule.
Invalidates the last SCF/gradient/polarizability result (invalidate_runs) and any TRC_GUESS_GIVEN density: a density from the OLD electron count’s own occupation is not a guess for the new one, even where its shape happens to still match, so the guess kind resets to TRC_GUESS_SAD. Every other guess kind (CORE/GWH/SAD/SADQ/SAP) carries no state keyed to the old charge and is left as the caller set it.
- Arguments:
- handletype(c_ptr), value
- chargeinteger(kind=c_int), value
- multiplicityinteger(kind=c_int), value
- Returns:
- statusinteger(kind=c_int)
trc_set_basis_libcint (function)
-
function trc_set_basis_libcint(handle, atm, natm, bas, nshell, env, nenv, cartesian) -> status The orbital basis from libcint’s packed
atm/bas/env.cartesiannonzero builds terco’s own Cartesian AO space; zero tags it spherical (libcint/pyscf order, m = -l..l except p as x, y, z) – trc_nao and every SCF-facing entry then size and index at nao_sph, exactly as for a spherical trc_set_basis_json. A mismatch against an already-set auxiliary or jkfit basis’s own convention is refused, not coerced.- Arguments:
- handletype(c_ptr), value
- atminteger(kind=c_int), intent(in), dimension(*)
- natminteger(kind=c_int), value
- basinteger(kind=c_int), intent(in), dimension(*)
- nshellinteger(kind=c_int), value
- envreal(kind=c_double), intent(in), dimension(*)
- nenvinteger(kind=c_int), value
- cartesianinteger(kind=c_int), value
- Returns:
- statusinteger(kind=c_int)
trc_set_aux_libcint (function)
-
function trc_set_aux_libcint(handle, atm, natm, bas, nshell, env, nenv, cartesian) -> status The auxiliary (RI-MP2 rifit) basis, same layout and
cartesianconvention as trc_set_basis_libcint; refused rather than coerced if it disagrees with the orbital basis already set.- Arguments:
- handletype(c_ptr), value
- atminteger(kind=c_int), intent(in), dimension(*)
- natminteger(kind=c_int), value
- basinteger(kind=c_int), intent(in), dimension(*)
- nshellinteger(kind=c_int), value
- envreal(kind=c_double), intent(in), dimension(*)
- nenvinteger(kind=c_int), value
- cartesianinteger(kind=c_int), value
- Returns:
- statusinteger(kind=c_int)
trc_set_basis_arrays (function)
-
function trc_set_basis_arrays(handle, nshell, maxnp, l, nprim, exps, coefs, centres) -> status - Arguments:
- handletype(c_ptr), value
- nshellinteger(kind=c_int), value
- maxnpinteger(kind=c_int), value
- linteger(kind=c_int), intent(in), dimension(*)
- npriminteger(kind=c_int), intent(in), dimension(*)
- expsreal(kind=c_double), intent(in), dimension(*)
- coefsreal(kind=c_double), intent(in), dimension(*)
- centresreal(kind=c_double), intent(in), dimension(*)
- Returns:
- statusinteger(kind=c_int)
trc_set_aux_arrays (function)
-
function trc_set_aux_arrays(handle, nshell, maxnp, l, nprim, exps, coefs, centres) -> status - Arguments:
- handletype(c_ptr), value
- nshellinteger(kind=c_int), value
- maxnpinteger(kind=c_int), value
- linteger(kind=c_int), intent(in), dimension(*)
- npriminteger(kind=c_int), intent(in), dimension(*)
- expsreal(kind=c_double), intent(in), dimension(*)
- coefsreal(kind=c_double), intent(in), dimension(*)
- centresreal(kind=c_double), intent(in), dimension(*)
- Returns:
- statusinteger(kind=c_int)
trc_set_basis_json (function)
-
function trc_set_basis_json(handle, path) -> status - Arguments:
- handletype(c_ptr), value
- pathcharacter(kind=c_char, len=1), intent(in), dimension(*)
- Returns:
- statusinteger(kind=c_int)
trc_set_aux_json (function)
-
function trc_set_aux_json(handle, path) -> status - Arguments:
- handletype(c_ptr), value
- pathcharacter(kind=c_char, len=1), intent(in), dimension(*)
- Returns:
- statusinteger(kind=c_int)
trc_set_ecp_json (function)
-
function trc_set_ecp_json(handle, path) -> status An explicit effective core potential, a MolSSI BSE JSON file’s own
ecp_potentials/ecp_electrons– overriding auto-attach from the orbital basis file itself (ECP_DESIGN.md’s DECIDED rule 2: a basis file that carries its own ecp_potentials attaches automatically when trc_set_basis_json loads it; this picks a DIFFERENT file instead). Call this BEFORE trc_set_basis_json: the attach itself happens there, once the molecule’s elements are known, so a basis already loaded is refused (TRC_ERR_STATE) rather than left stale. A caller still passes the BARE atomic number to trc_set_molecule either way – terco reduces it internally (at_z -= ncore per atom) and lowers the electron count by the same sum; nothing about trc_set_molecule or trc_set_charge changes.trc_set_basis_json refuses (TRC_ERR_BADARG) an orbital basis that is valence-only for an element this file has no ECP for, or one with another core count: every real atom whose basis entry carries ecp_potentials needs an ECP replacing exactly that many electrons. While this path is set, trc_set_basis_arrays and trc_set_basis_libcint are refused (TRC_ERR_STATE): neither can attach an ECP. trc_set_molecule clears it.
- Arguments:
- handletype(c_ptr), value
- pathcharacter(kind=c_char, len=1), intent(in), dimension(*)
- Returns:
- statusinteger(kind=c_int)
trc_set_method (function)
-
function trc_set_method(handle, functional, grid_level) -> status An empty functional name is Hartree-Fock.
- Arguments:
- handletype(c_ptr), value
- functionalcharacter(kind=c_char, len=1), intent(in), dimension(*)
- grid_levelinteger(kind=c_int), value
- Returns:
- statusinteger(kind=c_int)
trc_set_unrestricted (function)
-
function trc_set_unrestricted(handle, on) -> status Force UHF/UKS (two independent spin densities) even on a CLOSED shell (nalpha == nbeta), which otherwise runs restricted –
trc_scf_options_t%unrestricted’s own comment, “forced; an open shell is unrestricted regardless”: nalpha /= nbeta already gets nspin = 2 whether or not this is set, so this only changes anything on a singlet.onnonzero sets it; 0 (the default) restores restricted-when-closed-shell.- Arguments:
- handletype(c_ptr), value
- oninteger(kind=c_int), value
- Returns:
- statusinteger(kind=c_int)
trc_set_nlc_grid (function)
-
function trc_set_nlc_grid(handle, grid_level) -> status Grid level for VV10’s nonlocal correlation (default 1, coarser than the semilocal grid: VV10 is a double sum over its points). Only used by a functional with VV10, such as wB97X-V.
- Arguments:
- handletype(c_ptr), value
- grid_levelinteger(kind=c_int), value
- Returns:
- statusinteger(kind=c_int)
trc_set_pcm (function)
-
function trc_set_pcm(handle, model, eps, lebedev, radii_scale) -> status A polarisable continuum around the molecule for every SCF this context runs from here on (trc_pcm):
modelis “cpcm” or “iefpcm”, or an empty string to turn it off again.epsis the solvent’s dielectric constant and is required (water: 78.3553); there is no solvent-name table, so nothing is assumed from a name.lebedevis the points per atomic sphere andradii_scalethe van der Waals radius to cavity radius factor; 0 for either takes the default (302 and 1.2, pyscf’s). Additive: a context that never calls this runs exactly as before.- Arguments:
- handletype(c_ptr), value
- modelcharacter(kind=c_char, len=1), intent(in), dimension(*)
- epsreal(kind=c_double), value
- lebedevinteger(kind=c_int), value
- radii_scalereal(kind=c_double), value
- Returns:
- statusinteger(kind=c_int)
trc_set_pcm_radii (function)
-
function trc_set_pcm_radii(handle, natm, radii) -> status Override the PCM cavity radii table (trc_pcm_radii.F90) with explicit, FINAL (already-scaled) per-atom radii in bohr, trc_set_molecule’s own atom order – for a caller whose own PCM reference used a different van der Waals table or scale than terco’s default (pyscf’s modified Bondi, radii_scale 1.2): mqc’s own convention is plain Bondi (hydrogen 1.20 Angstrom, not terco’s 1.10) times 1.2, which the two backends otherwise disagree on by construction (water cpcm/PBE0: E_diel -0.011577 here against -0.010200 there, 556 against 566 kept surface points) – not a bug in either, a different cavity. This makes them agree by construction instead.
natm = 0, or a NULL radii, clears the override, back to the table and radii_scale; natm must otherwise equal the molecule’s own atom count. Invalidates the last SCF result, as trc_set_pcm does. Kept across trc_set_charge (the molecule, and so the cavity’s atoms, are unchanged); cleared by trc_set_molecule, which can change the atom count and order the override was given in.
A GHOST atom (trc_set_elements) would get no PCM sphere, so an entry here for one is IGNORED, not refused: the override is only ever read for an atom that still has a sphere to place. (PCM with ghosts is refused at trc_run_scf for now; see elements_refusal.)
- Arguments:
- handletype(c_ptr), value
- natminteger(kind=c_int), value
- radiitype(c_ptr), value
- Returns:
- statusinteger(kind=c_int)
trc_pcm_energy (function)
-
function trc_pcm_energy(handle, e_diel, q_total, npoints) -> status The continuum’s part of the last SCF: E_diel = q.v/2 (already in trc_energy’s total), the total apparent surface charge, and the surface points the cavity kept. Zeros when no continuum was set.
- Arguments:
- handletype(c_ptr), value
- e_dielreal(kind=c_double), intent(out)
- q_totalreal(kind=c_double), intent(out)
- npointsinteger(kind=c_int), intent(out)
- Returns:
- statusinteger(kind=c_int)
trc_set_convergence (function)
-
function trc_set_convergence(handle, conv_energy, conv_diis, max_iter, ndiis) -> status - Arguments:
- handletype(c_ptr), value
- conv_energyreal(kind=c_double), value
- conv_diisreal(kind=c_double), value
- max_iterinteger(kind=c_int), value
- ndiisinteger(kind=c_int), value
- Returns:
- statusinteger(kind=c_int)
trc_set_lindep (function)
-
function trc_set_lindep(handle, threshold) -> status Canonical orthogonalisation threshold: an eigenvalue of S, normalised to a unit diagonal first (pyscf’s
remove_linear_dep_/ORCA’s own convention – S itself is not unit-diagonal), belowthresholdis linear dependence and its direction is dropped from the SCF (and, for a positive threshold, from the minao guess’s projection). Default 1e-8. A diffuse basis on a large molecule can need more: GPU4PySCF converges a def2-TZVPD nitrosamine anion only at 5e-6 (40 functions dropped). 0 means plain symmetric orthogonalisation in the SCF, which stops when S is not numerically positive definite; the minao guess’s projection always keeps a floor, so at 0 it uses its own default (1e-8) rather than none. Takes effect at the next trc_run_scf.- Arguments:
- handletype(c_ptr), value
- thresholdreal(kind=c_double), value
- Returns:
- statusinteger(kind=c_int)
trc_set_screening (function)
-
function trc_set_screening(handle, thresh) -> status - Arguments:
- handletype(c_ptr), value
- threshreal(kind=c_double), value
- Returns:
- statusinteger(kind=c_int)
trc_set_incremental (function)
-
function trc_set_incremental(handle, on) -> status Incremental Fock builds: after the first iteration, G is accumulated from the density DIFFERENCE, which screens far harder as the SCF converges (trc_scf_options_t%incremental has the measurements, trc_scf_incremental the schedule and its error argument; convergence is declared on a full build only). Nonzero on, the default of the library and of the terco CLI; 0 off. Not used under trc_set_df.
Incremental Fock builds, on (nonzero, the default) or off (0): after the first iteration the two-electron matrix is built from the change in the density and accumulated, with a full build on the iteration convergence is declared on (see trc_scf_incremental.F90). Not used with trc_set_df, whose builds are always full. Takes effect at the next trc_run_scf.
- Arguments:
- handletype(c_ptr), value
- oninteger(kind=c_int), value
- Returns:
- statusinteger(kind=c_int)
trc_set_level_shift (function)
-
function trc_set_level_shift(handle, shift) -> status The virtual-orbital level shift, hartree; 0 turns it off. trc_scf_options_t%level_shift’s own comment: F += mu (S - S D S / occ), applied ONLY WHILE DIIS (AND ADIIS) ARE OFF – the damped start before either has engaged (trc_scf_driver.F90’s own “level shift while DIIS and A/EDIIS are off” block). It is a CONVERGENCE AID for that early phase: once the commutator is small enough for CDIIS (or ADIIS takes over first), this stops being applied, however large
shiftis set. To keep the shift on through DIIS until the commutator falls below a threshold – the sense a persistent level shift has in, for instance, a Fukui-ion deck’s convergence recipe – also setlevel_shift_untilwith trc_set_scf_stabilise.- Arguments:
- handletype(c_ptr), value
- shiftreal(kind=c_double), value
- Returns:
- statusinteger(kind=c_int)
trc_set_scf_accel (function)
-
function trc_set_scf_accel(handle, adiis, ndamp, damp, diis_start) -> status The SCF’s convergence aids beyond trc_set_convergence’s DIIS size and trc_set_level_shift (trc_scf_options_t’s own comments have the measurements behind each default):
adiis 1 turns on ADIIS (Hu & Yang) between the damped start and CDIIS; 0 off (the default). It earns its keep on hard cases – small gaps, charged open shells – where CDIIS alone stalls with |FDS - SDF| stuck near 1e-2. ndamp damped steps before DIIS; -1 by spin (0 closed shell, 4 open shell), the default. damp weight of the new density while damping, (0, 1]; default 0.3. diis_start commutator norm below which DIIS may start; -1 by spin, the default.
Takes effect at the next trc_run_scf, for every SCF the handle runs after it (trc_fukui_hirshfeld’s three included).
- Arguments:
- handletype(c_ptr), value
- adiisinteger(kind=c_int), value
- ndampinteger(kind=c_int), value
- dampreal(kind=c_double), value
- diis_startreal(kind=c_double), value
- Returns:
- statusinteger(kind=c_int)
trc_set_soscf (function)
-
function trc_set_soscf(handle, enable, soscf_start) -> status Second-order SCF (trc_scf_options_t%soscf’s own comment): once DIIS brings |FDS - SDF| below
soscf_start, hand over to a trust-region Newton step on the orbital rotations (trc_scf_soscf.F90, ported from metalquicha’s mqc_czt_soscf). Restricted Hartree-Fock only – refused at the next trc_run_scf with an open shell, a functional, a continuum solvent, –df or more than one rank, never run silently as plain DIIS.enable 1 turns –soscf on; 0 off (the default). soscf_start commutator norm at which DIIS hands over; -1 (or any value <= 0) for the library’s own default (1e-2).
Takes effect at the next trc_run_scf, for every SCF the handle runs after it.
- Arguments:
- handletype(c_ptr), value
- enableinteger(kind=c_int), value
- soscf_startreal(kind=c_double), value
- Returns:
- statusinteger(kind=c_int)
trc_set_scf_stabilise (function)
-
function trc_set_scf_stabilise(handle, mom, level_shift_until) -> status Two aids for small-gap SCFs (charged open shells, a Fukui ion) where CDIIS stalls with the occupation flipping between iterations. Both act on the eigenproblem of rank 0 alone, so unlike trc_set_soscf they are not refused with an open shell, a functional, a continuum solvent, –df or more than one rank (O3+ 6-31G* with both aids gives the same energy and iteration count on one, two and three devices, with and without IEF-PCM):
mom 1 occupies by maximum overlap with the previous density, starting at the first iteration with DIIS on and either a starting density the caller chose (trc_set_guess GIVEN, PROJECTED) or |FDS - SDF| < 0.1, and staying on; aufbau before that. The guesses terco builds itself (SAD, SADQ, SAP, MINAO, GWH, core) wait for the 0.1 gate. 0 aufbau throughout (the default). level_shift_until keep trc_set_level_shift’s shift on through DIIS until |FDS - SDF| falls below this; 0 (the default) drops it when DIIS starts. An iteration that can converge is never shifted. A shift this keeps on is dropped for the rest of the run, with one message, once the commutator has not improved by a factor 2 over 10 such iterations: a threshold below where the shifted run parks must not stop a run from converging.
Takes effect at the next trc_run_scf, for every SCF the handle runs after it (trc_fukui_hirshfeld’s three included). With
moma symmetry request of on/auto runs in C1 and a named group is refused. (ABI 1.26.)- Arguments:
- handletype(c_ptr), value
- mominteger(kind=c_int), value
- level_shift_untilreal(kind=c_double), value
- Returns:
- statusinteger(kind=c_int)
trc_set_gdm (function)
-
function trc_set_gdm(handle, on, start, max_rotation) -> status Geometric direct minimisation (Van Voorhis and Head-Gordon, Mol. Phys. 100, 1713 (2002)), an aid for SCFs that DIIS cannot converge: an L-BFGS minimisation over occupied-virtual orbital rotations that takes over from DIIS once |FDS - SDF| <
start, and accepts a step only if the energy does not rise (trc_scf_options_t%gdm has the details).on 1 turns GDM on; 0 off (the default). start commutator norm at which DIIS hands over; 0 for the library’s default (0.1). Must be >= 0. max_rotation largest element of the orbital rotation (kappa) of one step; 0 for the library’s default (0.2). Must be >= 0.
Works with restricted and unrestricted references, functionals (VV10 included), continuum solvents, density fitting and several ranks; refused at the next trc_run_scf together with fractional occupations and with trc_set_soscf. Measured caveats: it keeps the occupation it starts from, so started too early from a poor guess it can land on a higher state (the run warns when the final orbitals are not in aufbau order); with trc_set_scf_stabilise’s mom, a non-aufbau occupation held by MOM at the handover makes GDM decline and the run continues as a MOM run; and where DIIS works it is slower (about 1.8 times the iterations on a flat mode), so it is an aid for stalled cases, not a default. A 39-atom open-shell cation (UKS wB97X-V/def2-SVP, IEF-PCM) that DIIS left unconverged after 100 iterations converged in 46, to the same energy on 1, 2 and 3 GPUs.
Takes effect at the next trc_run_scf, for every SCF the handle runs after it (trc_fukui_hirshfeld’s three included). With
ona symmetry request of on/auto runs in C1 and a named group is refused. (ABI 1.27.)- Arguments:
- handletype(c_ptr), value
- oninteger(kind=c_int), value
- startreal(kind=c_double), value
- max_rotationreal(kind=c_double), value
- Returns:
- statusinteger(kind=c_int)
trc_set_df (function)
-
function trc_set_df(handle, on) -> status Density-fitted J and K (
--df). Needs a jkfit basis too (trc_set_jkfit_json, separate fromtrc_set_aux_json’s rifit set because one run can do DF-SCF and RI-MP2 with two different auxiliary bases) beforetrc_run_scf–trc_run_scfreports that, not this, since nothing here can tell whether one was already set by the time this is called.- Arguments:
- handletype(c_ptr), value
- oninteger(kind=c_int), value
- Returns:
- statusinteger(kind=c_int)
trc_set_jkfit_json (function)
-
function trc_set_jkfit_json(handle, path) -> status The fitting (jkfit) basis for
--df, a MolSSI BSE JSON file, read for the molecule already set – the same file formattrc_set_aux_jsonreads, into a SEPARATE slot (cx%jb). Follows the orbital basis’s own convention, exactlybasis_json’s rule for the rifit (aux) set: Cartesian when the orbital basis is (force_cartesian, or an orbital basis already loaded that is not itself spherical), its own JSON tag otherwise (def2-universal-jkfit is spherical, matching a spherical orbital basis –trc_scf_df.F90’sdf_jk_setupfolds it, see that module’s own header). Clears any fit already built on the previous jkfit basis.- Arguments:
- handletype(c_ptr), value
- pathcharacter(kind=c_char, len=1), intent(in), dimension(*)
- Returns:
- statusinteger(kind=c_int)
trc_set_jkfit_libcint (function)
-
function trc_set_jkfit_libcint(handle, atm, natm, bas, nshell, env, nenv, cartesian) -> status The same fitting basis as
trc_set_jkfit_json, from libcint’s packedatm/bas/envinstead of a JSON file – the same shapetrc_set_aux_libcinttakes.cartesianzero tags it spherical, exactly asbasis_libcintabove; refused rather than coerced if it disagrees with the orbital basis already set (pyscf’sauxmol.cart = mol.cart), since there is no file tag here to silently override.The –df fitting basis from libcint’s packed arrays, the same shape and
cartesianconvention as trc_set_aux_libcint; refused rather than coerced if it disagrees with the orbital basis already set (pyscf’s auxmol.cart = mol.cart rule).- Arguments:
- handletype(c_ptr), value
- atminteger(kind=c_int), intent(in), dimension(*)
- natminteger(kind=c_int), value
- basinteger(kind=c_int), intent(in), dimension(*)
- nshellinteger(kind=c_int), value
- envreal(kind=c_double), intent(in), dimension(*)
- nenvinteger(kind=c_int), value
- cartesianinteger(kind=c_int), value
- Returns:
- statusinteger(kind=c_int)
trc_set_batching (function)
-
function trc_set_batching(handle, res) -> status How finely the shell pairs are batched by their Schwarz bound:
resbuckets per decade. The pre-launch screen admits a pair of batches when their bounds multiply above the threshold, so a coarse bucket admits everything within its decade and leaves the rest to the test inside the kernel, where a rejected quartet has already cost a thread. Finer buckets catch more before the launch, at more and smaller batches. 1 is decades and is the default; 4 is the finest the bins are sized for. Rebuilds the ERI object, as a threshold change does.- Arguments:
- handletype(c_ptr), value
- resinteger(kind=c_int), value
- Returns:
- statusinteger(kind=c_int)
trc_set_force_cartesian (function)
-
function trc_set_force_cartesian(handle, flag) -> status Force the Cartesian AO space on every basis this context loads from here on, regardless of what a JSON file’s function_type says (trc_scf_options_t%force_cartesian).
flagnon-zero sets it.NOT RETROACTIVE: a basis already loaded (trc_set_basis_json) kept whichever space it was built in at that call – the same way trc_set_ao_norm’s own comment describes for a TRC_GUESS_GIVEN density already copied. Call this BEFORE trc_set_basis_json/ trc_set_aux_json for it to take effect on that basis; a caller wanting it to also apply to a basis already loaded has to load the file again.
- Arguments:
- handletype(c_ptr), value
- flaginteger(kind=c_int), value
- Returns:
- statusinteger(kind=c_int)
trc_set_guess (function)
-
function trc_set_guess(handle, kind, dguess, nspin) -> status kindone of TRC_GUESS_*. For TRC_GUESS_GIVEN,dguessis (nao, nao, nspin) column-major and is COPIED here; the caller’s array is free afterwards. The basis must be set first for that copy.CONTRAVARIANT under trc_set_ao_norm: a density given in TRC_AO_NORM_UNIT is converted to terco’s own shell-normalised convention here, once, at the copy – D_terco = N D_given N (see trc_ao_norm.F90’s header; this is the “guess coming IN” direction, the covariant congruence run forward). Everything downstream of this copy, including trc_run_scf’s own iteration, only ever sees terco’s native convention.
- Arguments:
- handletype(c_ptr), value
- kindinteger(kind=c_int), value
- dguesstype(c_ptr), value
- nspininteger(kind=c_int), value
- Returns:
- statusinteger(kind=c_int)
trc_set_ao_norm (function)
-
function trc_set_ao_norm(handle, kind) -> status How this context’s AO-indexed C API entries normalise a Cartesian shell’s components: TRC_AO_NORM_SHELL (0, the default – terco’s own convention, and libcint’s) or TRC_AO_NORM_UNIT (1 – every component individually normalised to 1, GAMESS’s convention; see trc_ao_norm.F90’s header for the closed form and which entries convert). Defaulting to SHELL means no caller that never calls this sees any difference from before this entry existed.
Order-independent of trc_set_basis* and trc_set_aux*: settable before or after either, and takes effect on whichever basis is present now and on any set afterwards. NOT retroactive on an already-copied TRC_GUESS_GIVEN density, though – that conversion happened once, at trc_set_guess’s own call, under whatever mode was active then; call this before trc_set_guess if the two must agree.
- Arguments:
- handletype(c_ptr), value
- kindinteger(kind=c_int), value
- Returns:
- statusinteger(kind=c_int)
trc_get_ao_norm (function)
-
function trc_get_ao_norm(handle, kind) -> status The AO normalisation this context is set to – TRC_AO_NORM_SHELL unless trc_set_ao_norm was called with TRC_AO_NORM_UNIT.
- Arguments:
- handletype(c_ptr), value
- kindinteger(kind=c_int), intent(out)
- Returns:
- statusinteger(kind=c_int)
trc_set_comm (function)
-
function trc_set_comm(handle, fcomm) -> status fcommis the Fortran handle of ANY intra-communicator the caller already has open and collective over – MPI_Comm_c2f from C, or the integer a Fortran caller holds (mpi_f08’s MPI_VAL, or the legacympimodule’s handle directly); -1 means one rank, no MPI. It need not be MPI_COMM_WORLD: GAMESS, for example, hands this DDI’s compute communicator, whose data-server ranks are not part of it and never call trc_run_scf/trc_run_rimp2 at all. terco duplicates whateverfcommnames (MPI_Comm_dup) the first time a run needs it, so every rank of THAT communicator must reach the run together; the caller keeps ownership of its own communicator, since only terco’s duplicate is ever freed.- Arguments:
- handletype(c_ptr), value
- fcomminteger(kind=c_int), value
- Returns:
- statusinteger(kind=c_int)
trc_set_verbose (function)
-
function trc_set_verbose(handle, level) -> status - Arguments:
- handletype(c_ptr), value
- levelinteger(kind=c_int), value
- Returns:
- statusinteger(kind=c_int)
trc_set_rimp2 (function)
-
function trc_set_rimp2(handle, nfrozen, aux_block) -> status nfrozen-1 counts the core from the elements;aux_block<= 0 is the whole auxiliary basis at once.- Arguments:
- handletype(c_ptr), value
- nfrozeninteger(kind=c_int), value
- aux_blockinteger(kind=c_int), value
- Returns:
- statusinteger(kind=c_int)
trc_set_rccsd (function)
-
function trc_set_rccsd(handle, triples, nfrozen, aux_block) -> status Closed-shell RI-CCSD, and with
triples1 the perturbative (T), for trc_run_rccsd; the auxiliary basis is trc_set_aux_json’s, the one RI-MP2 reads.nfrozenis the number of frozen core orbitals; -1 counts the core from the elements, as trc_set_rimp2 does.aux_blockis the auxiliary functions per three-index block while the integrals are built; 0 is the whole auxiliary basis at once, and the energy does not depend on it. These are this method’s own settings: RI-MP2’s (trc_set_rimp2) are left as they are. Clears a stored RI-CCSD result.- Arguments:
- handletype(c_ptr), value
- triplesinteger(kind=c_int), value
- nfrozeninteger(kind=c_int), value
- aux_blockinteger(kind=c_int), value
- Returns:
- statusinteger(kind=c_int)
trc_set_rccsd_convergence (function)
-
function trc_set_rccsd_convergence(handle, conv_energy, conv_amplitude, max_iterations, diis_size) -> status The RI-CCSD iteration’s stopping rule: it stops as converged when BOTH the change of the correlation energy between iterations is below
conv_energy(Eh) and the largest change of any amplitude is belowconv_amplitude.max_iterationscaps the iterations anddiis_sizeis the DIIS history length (1 switches DIIS off). Each 0 keeps the default: 1e-8, 1e-6, 100 and 8. A negative, NaN or infinite value is refused. A run that does not converge returns TRC_ERR_NOCONV. Clears a stored RI-CCSD result.- Arguments:
- handletype(c_ptr), value
- conv_energyreal(kind=c_double), value
- conv_amplitudereal(kind=c_double), value
- max_iterationsinteger(kind=c_int), value
- diis_sizeinteger(kind=c_int), value
- Returns:
- statusinteger(kind=c_int)
trc_set_rccsd_algorithm (function)
-
function trc_set_rccsd_algorithm(handle, ladder, triples_routine, triples_budget_mib) -> status How the particle-particle ladder is formed, which routine computes (T) and how much memory the tiled one may take; none of them changes the energy.
ladderis 0 to choose by operation count, 1 to assemble the (ac|bd) integrals in column batches, 2 to contract the three-index factors directly and never form them.triples_routineis 0 for the build’s default (the ijk routine in a device build, the reference one in a host build), 1 for the reference routine, which runs on the host from the host copies, 2 for the tiled routine, the device one over virtual triples, which also runs on the host, more slowly, 3 for the ijk routine, the device one over occupied triples.triples_budget_mibis the memory, in MiB and not necessarily whole, of the working tile of the routine that runs: the tiled routine’s W (6 o^3 doubles, 48 o^3 bytes per triple of virtuals, o active occupied orbitals) or the ijk routine’s Q (24 v^3 bytes per occupied triple, v virtual orbitals). 0 is the routine’s default: 1024 MiB for the tiled routine, 2048 MiB for the ijk one. Only the ijk routine raises its default to one triple when that is more, so its default never refuses; the tiled routine does not, and its 1024 MiB default does not hold one triple from o = 282. The reference routine has no budget. A budget below one triple of the routine that runs (the default one counts: the ijk routine in a device build and over several ranks; 1024 MiB holds one ijk triple only up to v = 355) makes the (T) step refuse once the RI-CCSD has converged (trc_run_rccsd returns TRC_ERR_UNSUPPORTED, the converged RI-CCSD stays readable). The tile is not all of (T)’s memory: the tiled routine’s repacked amplitudes come on top, and the ijk routine’s cache of integral slices is sized by the code, not by the budget: on a device build from the free device memory as max(min(0.8 free, free - 2 GiB) - the rest of its plan, 0) bytes, never fewer than 4 slices (so it can exceed 80 % of the free memory) nor more than 2 o; in a host build, or when the free memory is unknown, 16 GiB under the same clamp. A negative, NaN or infinite budget, or one above 1e12 MiB, is refused. Clears a stored RI-CCSD result.- Arguments:
- handletype(c_ptr), value
- ladderinteger(kind=c_int), value
- triples_routineinteger(kind=c_int), value
- triples_budget_mibreal(kind=c_double), value
- Returns:
- statusinteger(kind=c_int)
trc_run_scf (function)
-
recursive function trc_run_scf(handle) -> status Needs the molecule and the basis. Builds the guess it was asked for, runs, keeps everything in the context.
- Arguments:
- handletype(c_ptr), value
- Returns:
- statusinteger(kind=c_int)
trc_symmetry_requested (function)
-
function trc_symmetry_requested(handle) -> wanted Whether the caller EXPLICITLY asked for symmetry (not a bind(c) entry: for the geometry optimiser, which moves the atoms between runs and so cannot share a standard frame with a symmetric SCF, and refuses). The on/auto request is not one: see trc_symmetry_suppress_default.
- Arguments:
- handletype(c_ptr), intent(in)
- Returns:
- wantedlogical
trc_guess_is_user_chosen (function)
-
pure function trc_guess_is_user_chosen(kind) -> chosen Whether a TRC_GUESS_* kind starts the SCF from a density the caller chose, for
trc_scf_options_t%mom_follow_guess: a given one (which a restart or a Hessian displacement is) or a projected previous orbital set. The densities terco builds itself (SAD, SADQ, MINAO, and the core, GWH and SAP operators) are not: maximum overlap occupation must wait for the commutator gate before it follows them.- Arguments:
- kindinteger, intent(in)
- Returns:
- chosenlogical
trc_check_gradient_upfront (function)
-
function trc_check_gradient_upfront(handle) -> status Whether trc_run_gradient will refuse this context for a reason its molecule, basis and ECP settle before any SCF runs (a g basis function with an ECP attached, l above this build’s gradient kernels): TRC_OK when nothing known up front refuses it, otherwise TRC_ERR_UNSUPPORTED with the message (trc_message) trc_run_gradient would give. A geometry optimiser asks this before its first step (trc_dlfind_optimize): a refusal at the first gradient would otherwise reach DL-FIND, whose only answer to a failed evaluation is
error stop. Fortran only, not part of the C ABI: trc_opt_run reaches it through trc_dlfind_optimize.- Arguments:
- handletype(c_ptr), value
- Returns:
- statusinteger(kind=c_int)
trc_set_geometry (function)
-
function trc_set_geometry(handle, xyz) -> status Move every atom to a NEW geometry, same molecule and atom order
trc_set_moleculebuilt (same count, same nuclear charges, same charge/multiplicity) – the one call a geometry optimiser’s step loop needs between gradients. Built onhessian_set_geometry(trc_run_hessian’s own displacement primitive, PRIVATE until now): moves the orbital basis’s centres in place, and the auxiliary/ jkfit bases’ if present, then invalidates exactly as that routine does – the last SCF/gradient/polarizability/Hessian result, the DFT grid cache and the –df fit, all geometry-dependent.trc_set_moleculeis NOT a substitute for this: it replacescx%at_z/cx%at_rand invalidates the same things, but it never touches a basis already built (cx%bb/cx%ab/cx%jb) – the shells stay at their OLD centres, which is correct for setting up a NEW molecule before any basis exists, and wrong for moving the atoms of one that already has one. A caller wanting the latter (an optimiser, or trc_run_hessian’s own displacements) uses this.xyzis atom-major Bohr (x1 y1 z1 x2 …), the same conventiontrc_set_moleculetakes andtrc_gradientreturns, length 3*natm. A guess density/orbitals carried across the move (SAD stays SAD; TRC_GUESS_GIVEN’s density and TRC_GUESS_PROJECTED’s “this context’s last converged orbitals” are both still valid at the new geometry – that overlap-reprojection is exactly what TRC_GUESS_PROJECTED is for) is a caller choice, not this call’s.- Arguments:
- handletype(c_ptr), value
- xyzreal(kind=c_double), intent(in), dimension(*)
- Returns:
- statusinteger(kind=c_int)
trc_run_gradient (function)
-
function trc_run_gradient(handle) -> status The full analytic RHF/UHF nuclear gradient at the converged SCF this context already holds (trc_scf_grad%trc_scf_gradient: the one-electron terms, eri%gradient’s two-electron part, and nuclear repulsion – see that module’s own header for the assembly order and the factor of 1/2). When the orbital basis is spherical,
trc_scf_gradientitself folds D and W to the Cartesian space the derivative kernels need (T D T^T) before touching an integral; nothing here has to know which case it is in.Reuses
cx%la(initialised once per context bytrc_run_scf, released only attrc_destroy) rather than atrc_linalg_tof its own: a second handle here would need its own release before going out of scope (trc_linalg_t has no finalizer), for no reason – the gradient’s GEMMs are the same sizecx%lawas already sized for.NOT refused any more: a functional with VV10 nonlocal correlation (wB97X-V).
trc_scf_gradientadds trc_vv10_grad%vv10_grad_add’s term on top of the semilocal one, on VV10’s own grid (cx%opts%nlc_grid_level, the SAME level the SCF itself converged it on). Meta-GGAs run too (trc_xc_grad’s tau term), wB97M-V included: a meta-GGA with VV10 and its own range-separated exchange, each piece the same one its GGA counterpart uses.REFUSED, clearly, rather than attempted:
a double hybrid on a meta-GGA base (none is registered): its relaxed gradient would need a meta-GGA CPKS kernel.
RI-MP2 over anything but a restricted RHF or LDA/GGA KS reference on one rank: an unrestricted one (UHF, UKS), a meta-GGA, range-separated or VV10 functional, a spin-component-scaled double hybrid (none is registered), a multi-rank context, or dropped functions (gradient_capability_check’s own messages).
RI-CCSD (ABI 1.37). After a converged trc_run_rccsd without (T) this is d(E_RHF + E_RI-CCSD)/dR, frozen core included, as the run’s trc_set_rccsd had it (trc_rccsd_grad%trc_rccsd_gradient: Lambda, densities, Z-vector, derivative integrals). The integrals are rebuilt and the solver restarted from the amplitudes the run left on the host (one iteration on water/cc-pVDZ), so no device memory is held between the two calls. trc_set_rccsd_convergence’s thresholds, iteration limit and DIIS size also drive the Lambda equations: the gradient is as converged as they are (water/cc-pVDZ with the SCF and amplitudes at their defaults: 1e-8 Eh/Bohr from pyscf). trc_set_rccsd’s aux_block does not bound the gradient’s own three-index blocks, which are sized from the free device memory. Refused, TRC_ERR_UNSUPPORTED (what the settings decide, trc_check_rccsd_gradient says before the SCF): RI-CCSD(T), an open-shell or Kohn-Sham reference, an effective core potential, PCM, a –df reference, an SCF taken from a file (trc_load_scf), a basis above the derivative kernels’ ceilings, ghost atoms, a frozen orbital degenerate with a correlated one, more than one rank, device memory that does not fit. TRC_ERR_NOCONV when the Lambda or Z-vector equations do not converge. After a RI-CCSD that did not converge the gradient is the SCF’s, as trc_energy is. trc_run_hessian still refuses after RI-CCSD.
RI-MP2 AND DOUBLE HYBRIDS. After a successful trc_run_rimp2 the energy this context reports (trc_energy) is E_ref + c E_RI-MP2 – E_ref the RHF or KS energy, c a double hybrid’s PT2 fraction or one – and this differentiates THAT: trc_rimp2_grad%trc_rimp2_gradient, with the same frozen core, pair-list threshold and (for a KS reference) functional and grid settings the energy used. A four-centre reference keeps its Z-vector against the exact orbital Hessian (CPHF, or CPKS with the XC kernel); a –df one (trc_set_df) differentiates the fitted SCF it converged, its Z-vector, potentials and two-electron derivative all over
cx%dfjk(the XC kernel and potential derivative on the SCF’s grid). A later trc_run_scf clears the RI-MP2 result, and the gradient is the SCF’s again. (ABI 1.15: a double hybrid’s gradient was refused before.)–df outside the DF-SCF’s own scope (unrestricted, range-separated – the SCF refuses those first), or with the fit gone. A –df gradient otherwise runs the FITTED J/K gradient (trc_scf_grad_df.F90) over
cx%dfjk, the fit the SCF used. (ABI 1.34: a spherical orbital basis was refused before.)
NOT refused any more: PCM (C-PCM/IEF-PCM).
trc_scf_runreleases its own continuum at the end of a run, the same as its pair list and ERI engine (trc_scf_grad.F90’s own header), so this rebuilds one fresh, below, atcx%opts%pcm_model/pcm_eps/pcm_lebedev/pcm_radii_scale/pcm_radii_override– the SAME settingstrc_run_scfbuilt its own continuum with, at a geometrycx%scf_okalready guarantees is unchanged.trc_scf_gradientsolves it at this run’s own density (one more triangular solve through the already-factored K) and adds grad_qv + grad_nuc + grad_solver (trc_pcm_grad%pcm_grad_add’s own header).A multi-rank context (
cx%fcomm /= -1) is NOT refused: the gradient is not rank-split yet, so rank 0 computes it alone and broadcasts it, with a warning (see the comment at the call). Only rank 0’s device rebuilds the full pair list, Schwarz screen and ERI structures for it, which is the memory a split SCF avoided; a real split is the follow-up.eri%gradientitself already supports one (this%rank/this%nranks,sum_ranks’s allreduce) oncetrc_scf_gradientpasses itseri%buildacomm.A plain LDA/GGA functional, a GLOBAL hybrid of one (b3lyp and friends), or a RANGE-SEPARATED hybrid (wb97x and friends: nonzero
func%omega/exx_lr,nlc_b/nlc_cstill zero) is NOT refused:funcis looked up again here (samexc_functional_by_nametrc_set_method already validated the name with) and handed totrc_scf_gradient, along with the SAME grid settings (cx%opts%grid_level,grid_max_pts,rho_tol) the SCF itself converged with – the gradient’s quadrature has to be the SCF’s, or the two are not derivatives of the same energy.trc_scf_gradientitself builds the erf(omega r)/r long-range exchange term (a second eri%gradient pass, its own header) and trc_xc_grad%xc_grad_add computes the functional’s semilocal GGA part exactly as for any other GGA – see that module’s own header on whyomega/exx_lrdo not affect it.GRID REUSE.
cx%kgrid, the SCF’s own grid(s) kept alive sincetrc_run_scf(context_box%kgrid’s own header), is handed straight totrc_scf_gradientwhen it is built AND matches every setting the gradient’s quadrature has to match the SCF’s on (reuse_grid/reuse_nlc, below) – the same list this routine’s own header already promises (grid level, max points per batch, rho_tol, nlc grid level); geometry and basis are covered for free, because ANY change to either would have clearedcx%scf_ok(invalidate_runs) before this point could ever be reached. Otherwisetrc_scf_gradientrebuilds exactly as it always has – this is a pure performance path, never a correctness one:grid/xgare read-only there, so a mismatch caught here is the only thing standing between “reuse” and “quietly wrong”.- Arguments:
- handletype(c_ptr), value
- Returns:
- statusinteger(kind=c_int)
trc_gradient (function)
-
function trc_gradient(handle, grad) -> status (3, natm), Eh/Bohr, column-major (x, y, z fastest, then atom, the same atom order
trc_set_moleculewas given) – after a successfultrc_run_gradient. NOT AO-indexed data (see trc_capi.F90’s own “AO NORMALISATION” header): a nuclear gradient is a derivative of the SCF energy, which does not depend on which AO normalisation convention computed it, sotrc_set_ao_normplays no role here.- Arguments:
- handletype(c_ptr), value
- gradreal(kind=c_double), intent(out), dimension(*)
- Returns:
- statusinteger(kind=c_int)
trc_check_rccsd_gradient (function)
-
function trc_check_rccsd_gradient(handle) -> status Whether an RI-CCSD gradient (trc_run_scf, trc_run_rccsd, trc_run_gradient) will be refused for this context’s CURRENT settings, answered before any SCF runs: TRC_OK when nothing known up front refuses it, otherwise the status and message (trc_message) – TRC_ERR_STATE without a molecule, a basis or an auxiliary basis; TRC_ERR_UNSUPPORTED for RI-CCSD(T) (trc_set_rccsd), an open shell or trc_set_unrestricted, a functional, an effective core potential, PCM, density fitting (trc_set_df), an SCF loaded from a file, symmetry with a named group, l above the derivative kernels’ ceilings, more than one rank. Collective over trc_set_comm’s communicator. What only a finished run knows (convergence, dropped functions, the occupation, degeneracies, memory) is not checked. (ABI 1.37.)
- Arguments:
- handletype(c_ptr), value
- Returns:
- statusinteger(kind=c_int)
trc_check_rimp2_gradient (function)
-
function trc_check_rimp2_gradient(handle) -> status Whether an RI-MP2/double-hybrid gradient (trc_run_scf, trc_run_rimp2, trc_run_gradient) will be refused for this context’s CURRENT settings, answered from the settings alone, before any SCF runs: TRC_OK when nothing known up front refuses it, otherwise the status and message (trc_message) trc_run_rimp2 or trc_run_gradient would give – no auxiliary basis, l above this build’s kernels, a reference outside the gradient’s scope (unrestricted, PCM, a spin-component-scaled double hybrid, a functional with no CPKS kernel), more than one rank. A geometry optimiser asks this before its first step (trc_opt_run with trc_opt_set_rimp2): a refusal there would otherwise reach DL-FIND, whose only answer to a failed evaluation is
error stop. What only a finished SCF knows (functions dropped by canonical orthogonalisation, trc_set_lindep) is not, and cannot be, checked here.- Arguments:
- handletype(c_ptr), value
- Returns:
- statusinteger(kind=c_int)
trc_set_hessian_step (function)
-
function trc_set_hessian_step(handle, step) -> status The Cartesian displacement trc_run_hessian’s central differences use, in Bohr; must be positive. Default 0.005: its truncation error, about 1e-5 Eh/Bohr^2 on water/STO-3G, sits well above the SCF noise trc_run_hessian’s tightened convergence leaves. Unchanged until this is called. Invalidates the last trc_run_hessian result (a Hessian at the OLD step is not a Hessian at the new one), not the SCF/gradient it is built from.
- Arguments:
- handletype(c_ptr), value
- stepreal(kind=c_double), value
- Returns:
- statusinteger(kind=c_int)
trc_hessian_step (function)
-
function trc_hessian_step(handle, step) -> status The displacement trc_run_hessian would use (or last used) – trc_set_hessian_step’s own default or override.
- Arguments:
- handletype(c_ptr), value
- stepreal(kind=c_double), intent(out)
- Returns:
- statusinteger(kind=c_int)
trc_run_hessian (function)
-
function trc_run_hessian(handle) -> status A finite-difference Cartesian Hessian from this context’s own analytic gradient, central differences at trc_set_hessian_step’s own h (default 0.005 Bohr) around the converged SCF this context already holds (trc_run_scf; trc_gradient’s reference “run the SCF first” state requirement, same as trc_run_gradient):
H[k,j] = (g_j(x + h e_k) - g_j(x - h e_k)) / (2h) Eh/Bohr^2
k = 3*(atom-1)+{x,y,z}, 1-based, row = the displaced coordinate, then symmetrised, H <- (H + H^T)/2. 6N displaced SCF+gradient pairs plus one more to restore the reference state (below).
REFUSED UP FRONT, before any displacement spends SCF time:
no SCF yet, or one that did not converge (TRC_ERR_STATE);
more than one rank (trc_set_comm): the loop below is already written so a later split is “rank r takes k = r, r+P, …” plus a reduction over the gradients, but nothing here runs that split yet (TRC_ERR_UNSUPPORTED);
anything trc_run_gradient itself would refuse (an RI-MP2/ double-hybrid reference outside the RI-MP2 gradient’s scope, –df outside its own scope – gradient_capability_check, the SAME check trc_run_gradient makes, so the two can never disagree about what runs);
PCM: the analytic PCM gradient is validated, a finite difference of it is not yet;
a non-positive step (trc_set_hessian_step already refuses one, so this is the backstop, not the primary gate).
RI-MP2 AND DOUBLE HYBRIDS. When this context holds an RI-MP2 result (trc_run_rimp2 after the reference SCF), every displaced SCF is followed by its own trc_run_rimp2, so each gradient is the correlated one trc_run_gradient returns there – the derivative of E_ref + c E_RI-MP2, the energy trc_energy reports (c a double hybrid’s PT2 fractions, or one) – and the Hessian is that energy’s. The restored reference gets its trc_run_rimp2 again too. (ABI 1.19: this was refused before.) Without an RI-MP2 result the Hessian is the SCF energy’s, as trc_run_gradient’s gradient is.
SCF CONVERGENCE AT THE DISPLACED POINTS. FD noise is of order (gradient error)/(2h) = 100x the gradient error at h = 0.005, so the displaced SCFs need tighter convergence than a single point (water/STO-3G: HESSIAN_MAX_CONV_ENERGY/HESSIAN_MAX_CONV_DIIS below say how much). This context’s OWN conv_energy/conv_diis (trc_set_ convergence) are tightened to at least those floors for every displaced SCF – never loosened, so a caller who already asked for tighter still gets it – and restored to the caller’s own values before this returns, success or failure.
WARM START. Every displaced SCF starts from THIS run’s own converged density (TRC_GUESS_GIVEN), not the previous displacement’s – no guess drift accumulates across 6N points. The reference density, this context’s guess kind/density and conv_energy/conv_diis are all restored before returning.
A displaced SCF that fails to converge, or a gradient that fails, stops the loop (TRC_ERR_NOCONV or whatever status that call returned) rather than filling the Hessian with whatever that point produced; the context is still restored to the reference geometry/density before returning, as on success.
RESTORING THE REFERENCE STATE. After the loop (success or failure), the geometry goes back to the one this context held when trc_run_hessian was called, and the reference SCF is RE-RUN (warm-started from its own converged density, so it reconverges in very few iterations) rather than merely remembered – cheap next to 6N displaced solves, and it leaves cx%res/cx%grad in whatever state an ordinary trc_run_scf leaves them (grad_ok false; call trc_run_gradient again for the reference gradient). This context’s guess kind/density, as set before this call, are restored afterwards too, for the same reason the convergence settings are: trc_run_hessian’s own internal warm start must not leak into what a caller sees after it returns.
trc_hessian reads the result out; cx%hess is deallocated and hess_ok left false on any failure, so a caller cannot read a partial Hessian by mistake.
- Arguments:
- handletype(c_ptr), value
- Returns:
- statusinteger(kind=c_int)
trc_hessian (function)
-
function trc_hessian(handle, hess) -> status (3natm, 3natm), Eh/Bohr^2, column-major, row/column k = 3*(atom-1)+{x,y,z} (trc_set_molecule’s own atom order) – after a successful trc_run_hessian. NOT AO-indexed data, same as trc_gradient: a Hessian is a second derivative of the SCF energy, independent of any AO normalisation convention.
- Arguments:
- handletype(c_ptr), value
- hessreal(kind=c_double), intent(out), dimension(*)
- Returns:
- statusinteger(kind=c_int)
trc_run_polarizability (function)
-
function trc_run_polarizability(handle) -> status The static dipole polarizability at the converged SCF this context already holds: CPHF (trc_cphf%trc_scf_polarizability) for RHF or UHF, Hartree-Fock only; CPKS (trc_cpks%trc_scf_polarizability_rks) when a functional is set – restricted only, trc_cpks has no unrestricted entry. Builds its own pair list and ERI engine at the context’s own screening threshold, and (for CPKS) its own XC grid from
cx%res%grid_r/grid_w– the SAME quadraturetrc_run_scfconverged the density with, since a CPKS response built on a different grid is not a derivative of the energy that converged. All three are released before returning;cx%lais reused, astrc_run_gradientreuses it.REFUSED, as
trc_run_gradientis and for the same reasons: a correlated (RI-MP2 or double-hybrid) reference,--df, PCM, or a multi-rank context. An unrestricted functional reference is refused here too (trc_cpkshas nothing else to call). A meta-GGA or double-hybrid functional cannot reach this point at all –trc_set_methodalready refused it.- Arguments:
- handletype(c_ptr), value
- Returns:
- statusinteger(kind=c_int)
trc_polarizability (function)
-
function trc_polarizability(handle, alpha) -> status The static dipole polarizability tensor
trc_run_polarizabilitycomputed, a.u., column-major (3, 3).- Arguments:
- handletype(c_ptr), value
- alphareal(kind=c_double), intent(out), dimension(*)
- Returns:
- statusinteger(kind=c_int)
trc_set_tddft (function)
-
function trc_set_tddft(handle, nroots, tda, singlet, target_root, grid_response) -> status What trc_run_tddft computes: the lowest
nrootsroots (at least 1), in the Tamm-Dancoff approximation whentdais non-zero (CIS for Hartree-Fock) and the full RPA (TDHF, Casida) when it is zero;singletmust be non-zero (triplets are not implemented and are TRC_ERR_UNSUPPORTED);target_rootis the root, 1-based and at mostnroots, whose gradient trc_run_gradient returns and whose total energy trc_tddft_energy reports;grid_response(non-zero, the default of a context that never calls this) differentiates the Kohn-Sham grid’s points and partition weights too, the exact derivative of this library’s energy, and zero gives the Pulay-only gradient (pyscf’s). Drops a stored TDDFT result.- Arguments:
- handletype(c_ptr), value
- nrootsinteger(kind=c_int), value
- tdainteger(kind=c_int), value
- singletinteger(kind=c_int), value
- target_rootinteger(kind=c_int), value
- grid_responseinteger(kind=c_int), value
- Returns:
- statusinteger(kind=c_int)
trc_set_tddft_convergence (function)
-
function trc_set_tddft_convergence(handle, conv_tol, max_iteration, cpks_tol, cpks_max_iteration, roots_per_sweep) -> status The solver’s settings; a zero resets that setting to its default (a call replaces all five).
conv_tol(1e-8) is the Davidson residual norm of the excitation energies,max_iteration(50) its iteration limit,cpks_tol(1e-9) andcpks_max_iteration(100) the Z-vector’s residual and iteration limit for the gradient,roots_per_sweepthe trc_tddft_grad batching (a tuning knob that does not change the numbers). A tolerance must be finite and not negative, otherwise TRC_ERR_BADARG. Drops a stored TDDFT result.- Arguments:
- handletype(c_ptr), value
- conv_tolreal(kind=c_double), value
- max_iterationinteger(kind=c_int), value
- cpks_tolreal(kind=c_double), value
- cpks_max_iterationinteger(kind=c_int), value
- roots_per_sweepinteger(kind=c_int), value
- Returns:
- statusinteger(kind=c_int)
trc_set_tddft_missed_root_iterations (function)
-
function trc_set_tddft_missed_root_iterations(handle, n) -> status The most Davidson iterations after the probe in which Ritz pairs beyond the buffer are still iterated, the guard against a missed root (default 0, which is what trc_set_tddft_convergence leaves alone; it was 24 before). 0 iterates none: the pairs that might hide a root are reported open (the window check and its warning) and the run needs fewer matvecs; a larger value, 24 for instance, trades matvecs against the missed-root guarantee. A negative
nis TRC_ERR_BADARG. A caller that goes on to differentiate a root it followed by index (trc_run_gradient, trc_opt_set_tddft) should set 24: at 0 a missed candidate can make the returned root another state, and the gradient is then that state’s. The terco CLI does so for –grad and –opt. Drops a stored TDDFT result. (ABI 1.31.)- Arguments:
- handletype(c_ptr), value
- ninteger(kind=c_int), value
- Returns:
- statusinteger(kind=c_int)
trc_set_tddft_density_screen (function)
-
function trc_set_tddft_density_screen(handle, on) -> status Whether the excited-state matvec of trc_run_tddft screens its two-electron integrals by the trial densities (non-zero, the default) or not (zero). Screened, a quartet is dropped when its Schwarz bound times the largest density block of its launch is below the integral threshold, the SCF Fock build’s criterion; the trial vectors are orthonormal, so the bound does not tighten as the solve converges. Unscreened is slower, and the run logs a warning that says so. The coupled-perturbed (Z-vector) solve of the gradient never screens this way. Drops a stored TDDFT result. (ABI 1.32.)
- Arguments:
- handletype(c_ptr), value
- oninteger(kind=c_int), value
- Returns:
- statusinteger(kind=c_int)
trc_check_tddft (function)
-
function trc_check_tddft(handle, gradient) -> status Whether trc_run_tddft (and, when
gradientis non-zero, trc_run_gradient after it) will be refused for this context’s CURRENT settings, answered from the settings alone, before any SCF runs: TRC_OK, or TRC_ERR_UNSUPPORTED with the message (trc_message) the run would give – a triplet, an unrestricted reference, a meta-GGA, range-separated, VV10 or double-hybrid functional, an f basis, a continuum solvent, more than one rank, an RI-MP2 or RI-CCSD result held, and withgradienta –df reference (the excited-state gradient over a fit is not implemented yet; the energies are, ABI 1.36). A geometry optimiser asks this before its first step. What only a finished SCF knows (functions dropped by canonical orthogonalisation) is not, and cannot be, checked here.- Arguments:
- handletype(c_ptr), value
- gradientinteger(kind=c_int), value
- Returns:
- statusinteger(kind=c_int)
trc_run_tddft (function)
-
function trc_run_tddft(handle) -> status The excitation energies, oscillator strengths and (RPA) de-excitation weights of the lowest trc_set_tddft roots at the converged closed-shell SCF this context holds, TDA or full RPA, Hartree-Fock or a LDA/GGA/global-hybrid functional (trc_tddft_run.F90’s header has the method). Builds its own pair list and ERI engine at the context’s screening threshold and, for Kohn-Sham, reuses the SCF’s grid when the context kept it. Results: trc_tddft_nroots, trc_tddft_energies, trc_tddft_character, trc_tddft_energy. (ABI 1.35: a spherical orbital basis was refused before. ABI 1.36: a –df reference was refused before; it is now solved over the fit the SCF converged with, and the pair list is the transition dipoles’ alone.)
After it, trc_run_gradient is the gradient of the TARGET root’s total energy (trc_set_tddft), grid response included unless it was turned off; a later trc_run_scf drops the result and the gradient is the SCF’s again. trc_run_hessian refuses.
Refused with TRC_ERR_STATE (no converged SCF, or a –df fit dropped since the SCF) or TRC_ERR_UNSUPPORTED (trc_check_tddft’s list, and a non-aufbau reference, RI-MP2/RI-CCSD results held, more than one rank, symmetry that is not lenient); TRC_ERR_NOCONV when the Davidson iteration does not converge.
- Arguments:
- handletype(c_ptr), value
- Returns:
- statusinteger(kind=c_int)
trc_tddft_nroots (function)
-
function trc_tddft_nroots(handle, nroots) -> status The number of roots trc_run_tddft solved: the length of the arrays trc_tddft_energies and trc_tddft_character fill (3 times it for the transition dipoles).
- Arguments:
- handletype(c_ptr), value
- nrootsinteger(kind=c_int), intent(out)
- Returns:
- statusinteger(kind=c_int)
trc_tddft_window_open (function)
-
function trc_tddft_window_open(handle, nopen) -> status The number of candidate Ritz pairs the missed-root check of the last trc_run_tddft left open (not iterated, cut short, or abandoned; 0 when the window is closed). Open candidates do not by themselves mean a root is missing: it is a root of a symmetry the guesses do not reach that they might hide. Iterate them with trc_set_tddft_missed_root_iterations. TRC_ERR_STATE when no TDDFT result is stored. (ABI 1.33.)
- Arguments:
- handletype(c_ptr), value
- nopeninteger(kind=c_int), intent(out)
- Returns:
- statusinteger(kind=c_int)
trc_tddft_energies (function)
-
function trc_tddft_energies(handle, n, omega, oscillator, ynorm, dipole) -> status The roots of the last trc_run_tddft, ascending:
omegaexcitation energies (hartree),oscillatorstrengths (length gauge),ynormthe sum of Y squared of the normalised (X, Y) (X.X - Y.Y = 1; zero for the TDA) anddipole(3, nroots), column-major, the transition dipoles <0|r|n> in atomic units. Each array holds trc_tddft_nroots values (the last 3 times that);nis the number of roots the caller’s arrays hold, and fewer than trc_tddft_nroots is TRC_ERR_BADARG (nothing is written).- Arguments:
- handletype(c_ptr), value
- ninteger(kind=c_int), value
- omegareal(kind=c_double), intent(out), dimension(*)
- oscillatorreal(kind=c_double), intent(out), dimension(*)
- ynormreal(kind=c_double), intent(out), dimension(*)
- dipolereal(kind=c_double), intent(out), dimension(*)
- Returns:
- statusinteger(kind=c_int)
trc_tddft_character (function)
-
function trc_tddft_character(handle, n, hole, particle, weight) -> status The dominant orbital pair of each root of the last trc_run_tddft:
hole, the occupied orbital counted down from the HOMO (1 = HOMO),particle, the virtual counted up from the LUMO (1 = LUMO), and the pair’sweight, its share of X^2 - Y^2. Orbital phases and the order within a degenerate pair do not enter, so the pair is comparable between geometries: an optimiser follows a state by it. Each array holds trc_tddft_nroots values;nis the number the caller’s arrays hold, and fewer is TRC_ERR_BADARG (nothing is written).- Arguments:
- handletype(c_ptr), value
- ninteger(kind=c_int), value
- holeinteger(kind=c_int), intent(out), dimension(*)
- particleinteger(kind=c_int), intent(out), dimension(*)
- weightreal(kind=c_double), intent(out), dimension(*)
- Returns:
- statusinteger(kind=c_int)
trc_tddft_target_root (function)
-
function trc_tddft_target_root(handle, target_root, nroots) -> status The root trc_set_tddft named as the target (1-based) and the number of roots it asked for: what the gradient and trc_tddft_energy follow. It answers before any run, from the settings, so an optimiser reads the root from the context instead of holding a second copy.
- Arguments:
- handletype(c_ptr), value
- target_rootinteger(kind=c_int), intent(out)
- nrootsinteger(kind=c_int), intent(out)
- Returns:
- statusinteger(kind=c_int)
trc_tddft_energy (function)
-
function trc_tddft_energy(handle, energy) -> status The total energy of the target root (trc_set_tddft): the SCF energy plus its excitation energy, hartree. This is the energy trc_run_gradient differentiates after trc_run_tddft; trc_energy stays the ground state’s.
- Arguments:
- handletype(c_ptr), value
- energyreal(kind=c_double), intent(out)
- Returns:
- statusinteger(kind=c_int)
trc_run_rimp2 (function)
-
function trc_run_rimp2(handle) -> status Needs a converged SCF in the context (restricted, or unrestricted – UHF or UKS, cx%res%nspin == 2) and an auxiliary basis. An unrestricted reference refuses more than one rank below (see trc_urimp2_run’s own header for why the restricted ring is not a clean generalisation here). The orbital basis may be spherical:
cx%res%cmo/eps(at whatever space the SCF ran in) are folded into the Cartesian, zero-padded spacetrc_rimp2_run/trc_urimp2_runthemselves run in byrimp2_driver_mo_to_cart(trc_rimp2_driver.F90’s own header says why the pad is exact). On one rank with a closed-shell reference the pair energies are deferred: computed by the first trc_energy or trc_rimp2_energy, or taken from the amplitudes of a trc_run_gradient that comes first, which then runs no separate energy step. The numbers are the same either way (to round-off); only when the work happens moves.- Arguments:
- handletype(c_ptr), value
- Returns:
- statusinteger(kind=c_int)
trc_run_rccsd (function)
-
function trc_run_rccsd(handle) -> status Closed-shell RI-CCSD, and (T) when trc_set_rccsd asked for it, on the converged restricted Hartree-Fock reference in the context, with the auxiliary basis trc_set_aux_json set. The equations are those of the DF-CCSD and (T) of PySCF’s rccsd/ccsd_t.
Refused, with TRC_ERR_STATE: no SCF has run, it did not converge, or no auxiliary basis was set. Refused, with TRC_ERR_UNSUPPORTED, each with its reason in trc_message: an unrestricted or open-shell reference, a Kohn-Sham one, an effective core potential, linearly dependent functions dropped (the message names trc_set_lindep), a non-aufbau reference (an occupation kept by mom or reached by gdm, as for trc_run_rimp2), the (T) routine over several ranks (above), a basis above this build’s density-fitting ceilings (TERCO_DF_LMAX, TERCO_DF_LMAX_AUX). A frozen core that leaves no occupied orbital is TRC_ERR_BADARG. A continuum solvent is not refused, as for RI-MP2: the correlation is computed on the orbitals of the solvated SCF without a solvent response of its own.
RI-MP2 and RI-CCSD share trc_energy, and the later run wins: a successful trc_run_rccsd drops a stored RI-MP2 result, and trc_run_rimp2 drops a stored RI-CCSD one. A refused run leaves the other method’s result alone; it drops its own method’s earlier one (as trc_run_rimp2 does), the result being that of the call just made.
TRC_ERR_NOCONV when the iteration does not converge; the last energies are then in trc_rccsd_energy (converged = 0), (T) is not run and trc_energy is the SCF energy. When the CCSD converged but (T) failed (for example for device memory), the return is the (T) status (TRC_ERR_UNSUPPORTED) with its message; trc_rccsd_energy still gives the converged CCSD with has_triples = 0, and trc_energy is the CCSD total. Device memory, with o active occupied orbitals, v virtual orbitals, naux auxiliary functions and diis the DIIS size: the iterations hold 14.8 o^2 v^2 + (o^2 + o v + v^2) naux + 2 diis (o v + o^2 v^2) doubles plus about 1.2 GB of ladder scratch (the coefficient 14.8 was fitted before the dense (ia|bc) block of o v^3 doubles was removed and has not been re-derived since, so it may be off by an unknown amount). (T) adds, by routine: the ijk one (the default in a device build and over ranks) 2 o^2 v^2 + 2 o^3 v doubles, its tile of trc_set_rccsd_algorithm (2 GiB by default) and a cache of integral slices sized from the free device memory (16 GiB on a host); the tiled one 2 o^2 v^2 + o^3 v doubles, its tile (1 GiB by default) and a dense (ia|bc) copy of o v^3 doubles built on entry. docs/sphinx/cli.md has the details worked out. Over ranks (trc_set_comm, one rank per device, every rank calls this together): the integrals are built on every rank, the CCSD iterations run on the first and its result and amplitudes reach the others, and the (T) is shared (only the occupied-driven device routine does so, and triples_routine 0 picks it over several ranks; 1 or 2 is TRC_ERR_UNSUPPORTED there). Every rank returns the same status and energies. After a converged run trc_run_gradient is the RI-CCSD gradient (its own header: not with (T), and only for the references it takes), and trc_run_hessian and trc_run_polarizability refuse. When the gradient can follow, the converged amplitudes (o v + o^2 v^2 doubles) stay in host memory until the result is dropped.
On a handle with trc_set_df the call releases the SCF’s density fit before the solve, converged or not (the solver fits its own integrals and the amplitudes need that device memory: 16 GB at (H2O)6 aug-cc-pVQZ). Until trc_run_scf runs again, which fits anew, trc_run_tddft returns TRC_ERR_STATE, and trc_run_rimp2 fits its own integrals where it would have reused the SCF’s (the same energy). The RI-CCSD gradient does not use the fit; where no RI-CCSD result is held (the run did not converge), a trc_run_gradient that needs the fit returns TRC_ERR_STATE until then.
- Arguments:
- handletype(c_ptr), value
- Returns:
- statusinteger(kind=c_int)
trc_rccsd_energy (function)
-
function trc_rccsd_energy(handle, e_mp2, e_ccsd, e_t, t1_diagnostic, iterations, converged, has_triples) -> status The last trc_run_rccsd, converged or not. All energies are CORRELATION energies in Hartree:
e_mp2the RI-MP2 correlation of the same reference and frozen core,e_ccsdthe RI-CCSD one (the last iterate whenconvergedis 0),e_tthe (T) correction (0 unlesshas_triplesis 1). Add trc_energy’s SCF part for totals: after a converged run trc_energy is already the CCSD (or CCSD(T)) total.t1_diagnosticis sqrt(|t1|^2 / (2 o));iterationsthe CCSD iterations run. TRC_ERR_STATE when no run has left a result.- Arguments:
- handletype(c_ptr), value
- e_mp2real(kind=c_double), intent(out)
- e_ccsdreal(kind=c_double), intent(out)
- e_treal(kind=c_double), intent(out)
- t1_diagnosticreal(kind=c_double), intent(out)
- iterationsinteger(kind=c_int), intent(out)
- convergedinteger(kind=c_int), intent(out)
- has_triplesinteger(kind=c_int), intent(out)
- Returns:
- statusinteger(kind=c_int)
trc_rccsd_energy_parts (function)
-
function trc_rccsd_energy_parts(handle, e_singles, e_doubles) -> status The RI-CCSD correlation energy of the last trc_run_rccsd, converged or not, as the two parts of the energy functional, in Hartree. With L(i,a,j,b) = 2 (ia|jb) - (ib|ja) over the correlated occupied and the virtual orbitals,
e_doublesis sum L t2(i,j,a,b), what t2 alone gives, ande_singlesis sum L t1(i,a) t1(j,b), the t1 t1 part. Their sum is trc_rccsd_energy’se_ccsd. There is no f_ov t1 term: the reference is canonical Hartree-Fock. (T) is not in either; trc_rccsd_energy reports it. TRC_ERR_STATE when no run has left a result. (ABI 1.29.)- Arguments:
- handletype(c_ptr), value
- e_singlesreal(kind=c_double), intent(out)
- e_doublesreal(kind=c_double), intent(out)
- Returns:
- statusinteger(kind=c_int)
trc_rccsd_dimensions (function)
-
function trc_rccsd_dimensions(handle, nfrozen, nactive_occ, nvirtual, naux) -> status The orbital spaces of the last trc_run_rccsd, converged or not:
nfrozenthe frozen core orbitals actually used (the elements’ own count when trc_set_rccsd asked for -1),nactive_occthe correlated occupied orbitals,nvirtualthe virtual orbitals andnauxthe auxiliary functions. TRC_ERR_STATE when no run has left a result.- Arguments:
- handletype(c_ptr), value
- nfrozeninteger(kind=c_int), intent(out)
- nactive_occinteger(kind=c_int), intent(out)
- nvirtualinteger(kind=c_int), intent(out)
- nauxinteger(kind=c_int), intent(out)
- Returns:
- statusinteger(kind=c_int)
trc_save_scf (function)
-
function trc_save_scf(handle, path) -> status Write the context’s SCF result – orbitals, orbital energies, density, energies – to
path(NUL-terminated), with the molecule, basis and method it belongs to; trc_load_scf reads it back. One rank is enough: every rank holds the same result.- Arguments:
- handletype(c_ptr), value
- pathcharacter(kind=c_char, len=1), intent(in), dimension(*)
- Returns:
- statusinteger(kind=c_int)
trc_load_scf (function)
-
function trc_load_scf(handle, path) -> status In place of trc_run_scf: take the SCF result from a file trc_save_scf wrote, so a correlated step (trc_run_rimp2) can follow without repeating the SCF. The molecule, basis, method and solvent must be set as for trc_run_scf, and must be the ones the file was made with; anything else is refused, naming the difference. Every rank reads the file itself. TRC_ERR_NOCONV if the saved SCF had not converged, as trc_run_scf would have said.
- Arguments:
- handletype(c_ptr), value
- pathcharacter(kind=c_char, len=1), intent(in), dimension(*)
- Returns:
- statusinteger(kind=c_int)
trc_cart_order (function)
-
function trc_cart_order -> order_id 0 (lexicographic) or 1 (gamess): the within-shell Cartesian order every AO-indexed array this API exchanges uses, fixed at compile time (TRC_CART_ORDER) and the same for every handle – no handle argument, and it always succeeds.
- Returns:
- order_idinteger(kind=c_int)
trc_abi_version (function)
-
function trc_abi_version(major, minor) -> status This build’s ABI version (TRC_ABI_MAJOR, TRC_ABI_MINOR above), so a host can compare it against the constants the header it compiled against carries before trusting any other entry point. Bump TRC_ABI_MINOR for an additive change (a new entry point, a new enum value appended at the end); bump TRC_ABI_MAJOR, and reset TRC_ABI_MINOR to 0, for anything that changes an existing signature or an existing enum value’s meaning. No handle; always succeeds.
- Arguments:
- majorinteger(kind=c_int), intent(out)
- minorinteger(kind=c_int), intent(out)
- Returns:
- statusinteger(kind=c_int)
trc_physical_constant (function)
-
function trc_physical_constant(id, value) -> status One of trc_constants’ own CODATA 2018 values, by the TRC_CONST_* selector above, so a host that keeps its own copy of these (a GAMESS-input front end converting Angstrom to Bohr, say) can read terco’s instead of carrying a second literal that can drift from this library’s. Process-wide; no handle; TRC_ERR_BADARG and
valueleft at 0 for anidthis build does not know (an older caller asking for a selector a newer header added, or a typo).TRC_CONST_BOHR_TO_ANGSTROM Bohr radius, Angstrom TRC_CONST_HARTREE_TO_EV Hartree energy, eV TRC_CONST_HARTREE_TO_KCALMOL Hartree energy, kcal/mol (the thermochemical calorie) TRC_CONST_AMU_TO_ME atomic mass unit, electron masses TRC_CONST_KB_SI Boltzmann constant, J/K TRC_CONST_NA_SI Avogadro constant, mol^-1
- Arguments:
- idinteger(kind=c_int), value
- valuereal(kind=c_double), intent(out)
- Returns:
- statusinteger(kind=c_int)
trc_functional_info (function)
-
function trc_functional_info(name, flags, exx, c_os, c_ss) -> status Look up a functional by name (case-insensitive, trc_xc_functional’s own table) without a context:
flagsis a bitmask –1 known – runnable today (trc_set_method would accept it) 2 hybrid – exx or exx_lr nonzero (some exact exchange) 4 range-separated – omega nonzero 8 VV10 – nlc_b nonzero (nonlocal correlation) 16 meta-GGA – depends on the kinetic-energy density tau; runs (bit 1) unless it also needs the density Laplacian (r2SCAN-L), which terco does not evaluate (bit 64) 32 double hybrid – xc_is_double_hybrid (pt2_cos or pt2_css nonzero) 64 listed but not runnable – trc_xc_functional_t%missing is set; bit 1 is then NOT set, and
exx/c_os/c_ss/the other bits reflect only whatever the table’s own entry set before giving up (most “missing” entries set nothing at all, so every other bit and output reads zero – that is the table’s gap, not this entry’s)exxis the fraction of ordinary (full-range) exact exchange;c_os/c_ssare the opposite-/same-spin RI-MP2 weights a double hybrid adds on top (both 0 for anything that is not one). An unknown name returns a non-OK status with flags = 0 and every output zeroed, rather than TRC_OK with nothing found.- Arguments:
- namecharacter(kind=c_char, len=1), intent(in), dimension(*)
- flagsinteger(kind=c_int), intent(out)
- exxreal(kind=c_double), intent(out)
- c_osreal(kind=c_double), intent(out)
- c_ssreal(kind=c_double), intent(out)
- Returns:
- statusinteger(kind=c_int)
trc_functional_list (function)
-
function trc_functional_list(buf, buflen, reqlen) -> status XC_AVAILABLE_FUNCTIONALS – every name trc_set_method/ trc_functional_info can look up that terco can actually run today – space-separated and NUL-terminated into
buf(capacitybuflenbytes, NUL included).reqlenis ALWAYS set to the number of bytes that call needed, NUL included, whether or not it fit: a caller queries it withbuflen = 0(bufis never touched then) and allocates exactlyreqlenbytes for a second, filling call. Returns TRC_ERR_BADARG, leavingbufuntouched, ifbuflenis positive but smaller thanreqlen.- Arguments:
- bufcharacter(kind=c_char, len=1), intent(out), dimension(*)
- bufleninteger(kind=c_int), value
- reqleninteger(kind=c_int), intent(out)
- Returns:
- statusinteger(kind=c_int)
trc_nao (function)
-
function trc_nao(handle, nao) -> status - Arguments:
- handletype(c_ptr), value
- naointeger(kind=c_int), intent(out)
- Returns:
- statusinteger(kind=c_int)
trc_nmo (function)
-
function trc_nmo(handle, nmo) -> status Molecular-orbital count:
trc_nao’s own AO count minus whatever canonical orthogonalisation dropped as linearly dependent at the lasttrc_run_scf(trc_scf_result_t%n_lindep– 0 for every compact basis, nonzero only for a diffuse one close to linear dependency). Before the firsttrc_run_scfthat count is unknown, sonmoistrc_nao’s own number.- Arguments:
- handletype(c_ptr), value
- nmointeger(kind=c_int), intent(out)
- Returns:
- statusinteger(kind=c_int)
trc_mo_occupations (function)
-
function trc_mo_occupations(handle, occ) -> status Occupation numbers, (nmo, nspin) column-major (
trc_nmo’s own size), for the last convergedtrc_run_scf: 2.0 per orbital up tonalphaand restricted (nspin 1), or 1.0 up tonalpha/nbetaon each spin’s own column (nspin 2); 0 above. REFUSED (TRC_ERR_UNSUPPORTED) if this context’s guess used fractional occupation: that per-orbital Aufbau split is private totrc_scf_run(its ownfrac_occupations) and not re-derivable from the stored result alone – unreachable through this C API today, since nothing here sets fractional occupation, but refused rather than silently wrong for a Fortran-driver-built context that did.- Arguments:
- handletype(c_ptr), value
- occreal(kind=c_double), intent(out), dimension(*)
- Returns:
- statusinteger(kind=c_int)
trc_is_spherical (function)
-
function trc_is_spherical(handle, flag) -> status Non-zero if the orbital basis this context holds is running in the spherical AO space (nao_sph of trc_nao, rather than the Cartesian nao) – the basis’s own JSON function_type unless force_cartesian overrode it. For a caller checking which space
trc_nao’s number, and every AO-indexed array it sizes, is in.- Arguments:
- handletype(c_ptr), value
- flaginteger(kind=c_int), intent(out)
- Returns:
- statusinteger(kind=c_int)
trc_nspin (function)
-
function trc_nspin(handle, nspin) -> status - Arguments:
- handletype(c_ptr), value
- nspininteger(kind=c_int), intent(out)
- Returns:
- statusinteger(kind=c_int)
trc_energy (function)
-
function trc_energy(handle, energy) -> status The SCF total, plus the RI-MP2 correlation if that ran: the FULL E_os + E_ss for a plain post-SCF RI-MP2 (any functional, or Hartree-Fock), or c_os E_os + c_ss E_ss for a double hybrid – trc_rimp2_energy below always reports the raw, unscaled E_os/E_ss either way, so a caller after the PT2 part alone never sees this weighting. A caller asking for a double hybrid’s total needs nothing beyond the ordinary trc_run_scf/trc_run_rimp2/trc_energy sequence any RI-MP2 run already uses – the weighting is applied here, once, from the functional’s own pt2_cos/pt2_css.
After a CONVERGED trc_run_rccsd it is the SCF total plus the CCSD correlation energy, plus the (T) correction when the run asked for it: the CCSD or the CCSD(T) total. A CCSD that did not converge adds nothing here (trc_rccsd_energy has its last iterate).
- Arguments:
- handletype(c_ptr), value
- energyreal(kind=c_double), intent(out)
- Returns:
- statusinteger(kind=c_int)
trc_energy_parts (function)
-
function trc_energy_parts(handle, e_nuc, e_one, e_two, e_xc) -> status - Arguments:
- handletype(c_ptr), value
- e_nucreal(kind=c_double), intent(out)
- e_onereal(kind=c_double), intent(out)
- e_tworeal(kind=c_double), intent(out)
- e_xcreal(kind=c_double), intent(out)
- Returns:
- statusinteger(kind=c_int)
trc_converged (function)
-
function trc_converged(handle, flag) -> status - Arguments:
- handletype(c_ptr), value
- flaginteger(kind=c_int), intent(out)
- Returns:
- statusinteger(kind=c_int)
trc_iterations (function)
-
function trc_iterations(handle, niter) -> status - Arguments:
- handletype(c_ptr), value
- niterinteger(kind=c_int), intent(out)
- Returns:
- statusinteger(kind=c_int)
trc_nelec_grid (function)
-
function trc_nelec_grid(handle, nelec) -> status The electron count the Kohn-Sham grid integrated the converged density to, the sanity check of a DFT run (it should sit within the quadrature error of the molecule’s electron count). 0 for a Hartree-Fock run, which has no grid. A result loaded with trc_load_scf reports the count the saved run stored in the file (the history, events and diagnostics, which the file does not hold, are empty).
- Arguments:
- handletype(c_ptr), value
- nelecreal(kind=c_double), intent(out)
- Returns:
- statusinteger(kind=c_int)
trc_scf_history_size (function)
-
function trc_scf_history_size(handle, nrows) -> status The rows of the last SCF’s iteration table that trc_scf_history copies out: one per iteration the SCF printed, the second-order phase’s included. 0 for a result loaded with trc_load_scf.
- Arguments:
- handletype(c_ptr), value
- nrowsinteger(kind=c_int), intent(out)
- Returns:
- statusinteger(kind=c_int)
trc_scf_history (function)
-
function trc_scf_history(handle, nrows, energy, delta_e, rms_density, commutator, mode, flags) -> status The SCF’s iteration table,
nrows(trc_scf_history_size) entries of each array: the total energy, its change from the previous iteration (the first row’s is the first energy itself: the table starts from 0), the density change sqrt(sum dD^2)/nao, summed over both spins of an unrestricted run (the table’s RMS(D); -1 on a second-order step, which has none), the commutator norm sqrt(sum errv^2) of the orthogonalised errv = X^T (FDS - SDF) X, summed over both spins of an unrestricted run (the DIIS error that trc_set_convergence’s conv_diis gates, not the AO-basis norm of FDS - SDF), the accelerator that stepped the orbitals (0 plain or damped, 1 CDIIS, 2 ADIIS, 3 the diagonalisation GDM hands over from, 4 a GDM step, 5 a second-order step) and the sum of the bits 1 (the Fock build was an increment), 2 (the level shift was applied) and 4 (MOM followed the density). What the run already decided; nothing is recomputed.- Arguments:
- handletype(c_ptr), value
- nrowsinteger(kind=c_int), value
- energyreal(kind=c_double), intent(out), dimension(*)
- delta_ereal(kind=c_double), intent(out), dimension(*)
- rms_densityreal(kind=c_double), intent(out), dimension(*)
- commutatorreal(kind=c_double), intent(out), dimension(*)
- modeinteger(kind=c_int), intent(out), dimension(*)
- flagsinteger(kind=c_int), intent(out), dimension(*)
- Returns:
- statusinteger(kind=c_int)
trc_scf_events (function)
-
function trc_scf_events(handle, events) -> status What the last SCF decided, TRC_SCF_NEVENTS (10) integers: (1) Fock builds taken as increments, (2) GDM steps (rejected trials included), (3) GDM trials rejected, (4) GDM’s off-aufbau virtuals at the end, (5) GDM declined at the handover because MOM held a non-aufbau occupation, (6) the level-shift stall guard dropped the shift, (7) the DIIS iteration the second-order phase took over after (0 never), (8) the most orbitals MOM held above the aufbau set, (9) functions dropped as linearly dependent, (10) the symmetric run was declined and ran in C1. Flags are 0 or 1. After trc_load_scf all are 0 except (9), which the file restores.
- Arguments:
- handletype(c_ptr), value
- eventsinteger(kind=c_int), intent(out), dimension(*)
- Returns:
- statusinteger(kind=c_int)
trc_diagnostics (function)
-
function trc_diagnostics(handle, values) -> status Counters the last SCF already holds, TRC_NDIAGNOSTICS (8) integers, 0 where the run had no such thing: (1) points of the Kohn-Sham grid, (2) points of VV10’s grid, (3) the symmetric run used the skeleton Fock build, (4) atoms inequivalent under the symmetry group (the size rule’s count), (5) functions of the RI-MP2/RI-CCSD auxiliary basis, (6) functions of the density-fitting J/K auxiliary basis, (7) Fock builds of the main loop, (8) an effective core potential is attached. After trc_load_scf, (1)-(4) and (7) are 0; (5), (6) and (8) describe the handle’s setup (the auxiliary basis sets and the ECP set before the load), not the file’s run.
- Arguments:
- handletype(c_ptr), value
- valuesinteger(kind=c_int), intent(out), dimension(*)
- Returns:
- statusinteger(kind=c_int)
trc_set_gradient_grid_response (function)
-
function trc_set_gradient_grid_response(handle, flag) -> status Whether the Kohn-Sham ground-state gradient (trc_run_gradient, and the Hessian built from it) differentiates the grid’s points and partition weights too. Non-zero, the default of a context that never calls this, is the exact derivative of this library’s energy; zero gives the Pulay terms only, pyscf’s default, which differs by about 1e-5 Eh/Bohr on water PBE. No effect for Hartree-Fock. The RI-MP2 and TDDFT gradients keep their own settings (trc_set_tddft). Drops the stored gradient.
- Arguments:
- handletype(c_ptr), value
- flaginteger(kind=c_int), value
- Returns:
- statusinteger(kind=c_int)
trc_density (function)
-
function trc_density(handle, dmat) -> status (nao, nao, nspin), column-major; restricted holds the total. After a symmetric run reported in the input frame, rotated back exactly (D_in = D D_std D^T, trc_sym_frame).
CONTRAVARIANT under trc_set_ao_norm: D_out = N^-1 D_terco N^-1 per spin slice when UNIT. Scaled on a COPY –
cx%res%dmatitself stays in terco’s own convention, because trc_run_rimp2 and a second trc_run_scf both read it as such internally.- Arguments:
- handletype(c_ptr), value
- dmatreal(kind=c_double), intent(out), dimension(*)
- Returns:
- statusinteger(kind=c_int)
trc_hirshfeld_charges (function)
-
function trc_hirshfeld_charges(handle, charges) -> status Hirshfeld atomic charges from the converged density, one per atom in
trc_set_molecule’s own order –trc_hirshfeld.F90’s stockholder partition (Hirshfeld, Theor. Chim. Acta 44, 129 (1977)), with the free atoms H-Kr’s fixed wB97X/def2-TZVP recipe. Works for RHF/UHF/RKS/UKS and with C-PCM/IEF-PCM (the charge analysis never touches the solvent operator, only the converged density). TRC_ERR_BADARG for an element outside H-Kr, or for an effective core potential attached (refused separately – the free-atom reference is all-electron, state_hirshfeld_charges); TRC_ERR_STATE when the free-atom data file cannot be read (set TRC_HIRSHFELD_DATA).- Arguments:
- handletype(c_ptr), value
- chargesreal(kind=c_double), intent(out), dimension(*)
- Returns:
- statusinteger(kind=c_int)
trc_dipole_moment (function)
-
function trc_dipole_moment(handle, mu) -> status The electric dipole moment of the converged SCF determinant (a MOM excited state when MOM held one), atomic units, x y z: mu = sum_A Z_A R_A - Tr(D r) with the TOTAL density D, origin at (0, 0, 0) of the frame the getters report (the input frame when the molecule was moved to a standard one; a named point group reports the standard frame). The vector of a charged molecule depends on that origin. Z_A is the charge the SCF used: 0 on a ghost, Z minus the core electrons on an ECP atom. A PCM run reports the polarised solute’s own dipole, without the apparent surface charges. Works for RHF/UHF/RKS/UKS and any occupation. TRC_ERR_UNSUPPORTED when the basis has a shell above d (the dipole integrals stop there), or when host memory for the scratch cannot be had; a device out-of-memory cannot be caught. A pure function of the converged density: a Cartesian or spherical basis and either AO normalisation give the same vector. (ABI 1.38.)
- Arguments:
- handletype(c_ptr), value
- mureal(kind=c_double), intent(out), dimension(3)
- Returns:
- statusinteger(kind=c_int)
trc_spin_square (function)
-
function trc_spin_square(handle, s2, multiplicity) -> status <S^2> of the converged unrestricted determinant (a MOM excited state’s own, when MOM held one) and the multiplicity 2S + 1 = sqrt(4 <S^2> + 1) it implies, as pyscf’s
spin_square: Sz (Sz + 1) + N_beta - Tr(D_a S D_b S). Hartree-Fock and Kohn-Sham alike (the Kohn-Sham orbitals’ determinant). TRC_ERR_UNSUPPORTED for a restricted run (nspin 1: the value would be zero by construction, ask only an unrestricted one) and for fractional occupations. A property of the density matrices and the overlap, so it does not depend on the report frame. (ABI 1.38.)- Arguments:
- handletype(c_ptr), value
- s2real(kind=c_double), intent(out)
- multiplicityreal(kind=c_double), intent(out)
- Returns:
- statusinteger(kind=c_int)
trc_chelpg_charges (function)
-
function trc_chelpg_charges(handle, charges) -> status CHELPG atomic charges from the converged density, one per atom in
trc_set_molecule’s own order: point charges on the nuclei fitted to the molecule’s electrostatic potential on Breneman and Wiberg’s grid (J. Comput. Chem. 11, 361 (1990); 0.3 Angstrom spacing, 2.8 Angstrom head space, Bondi radii), constrained to sum to the molecular charge –trc_chelpg.F90, metalquicha’s recipe. Works for RHF/UHF/RKS/UKS (the total density) and with C-PCM/IEF-PCM (the potential fitted is the solute’s own, its nuclei and its polarised density, without the apparent surface charges). TRC_ERR_BADARG for a ghost atom, an element without a tabulated radius, or a basis above this build’s potential-integral ceiling. Every rank of a multi-rank run computes the same charges (the analysis is replicated, like trc_hirshfeld_charges). (ABI 1.21.)- Arguments:
- handletype(c_ptr), value
- chargesreal(kind=c_double), intent(out), dimension(*)
- Returns:
- statusinteger(kind=c_int)
trc_fukui_hirshfeld (function)
-
function trc_fukui_hirshfeld(handle, f_plus, f_minus, f_zero, q_n, q_np1, q_nm1) -> status Hirshfeld-condensed Fukui indices by finite difference in the electron count, ported from metalquicha’s mqc_czt_fukui (fukui_indices/fukui_from_states, “hirshfeld” scheme only): three SCFs on THIS handle – the converged neutral already here, plus N+1 and N-1, both doublets –
f_A+ = q_A(N) - q_A(N+1) f_A- = q_A(N-1) - q_A(N)
condensed by trc_hirshfeld_populations, the SAME partition for all three states (mqc_czt_fukui.f90’s own header: “the three calculations share one czt_molecule_t, so they see the same geometry and the same basis functions by construction” – here, the same context_box, and trc_set_charge keeps the SAME basis and –df fit across all three, its own header).
ONLY for a closed-shell neutral (multiplicity 1, at least two electrons): mqc’s own fukui_indices refuses anything else, verbatim – a radical’s ions are not both doublets, and guessing what they should be is a caller decision this entry point does not make.
Each ion runs UNSEEDED, from the handle’s own guess kind (so
--guess minaoreaches the ions: a SAD guess stalls an NA-040-type nitrosamine anion that minao converges), except that SAD becomes SADQ, the charged-atom guess the CLI picks for any ion, and a guess that is a stored density (TRC_GUESS_GIVEN, TRC_GUESS_PROJECTED) belongs to the neutral, so the ions fall back to TRC_GUESS_GWH, mqc’s own default when no neutral orbitals are offered. A caller wanting the neutral’s orbitals to seed the ions instead (mqc’s “neutral” mode) drives the three states by hand: trc_set_charge, trc_set_guess(TRC_GUESS_GIVEN, …) and trc_run_scf, exactly what this function does internally but with its own density.Leaves the handle’s charge and multiplicity as it found them: restored after the two ion SCFs, and the neutral SCF is RE-RUN (warm-started from its own converged density) before this returns, success or failure – trc_run_hessian’s own restore pattern (same file, below), because cx%res has to match cx%charge/cx%multiplicity again, not merely the two scalar fields.
TRC_ERR_STATE: no converged SCF yet. TRC_ERR_BADARG: multiplicity is not 1, fewer than two electrons, an element outside Hirshfeld’s H-Kr recipe, or the condensed indices failing their one-electron sum rule. TRC_ERR_NOCONV: an ion did not converge. With more than one rank (trc_set_comm) every rank must make this call, as for trc_run_scf: the three SCFs are collective, and the Hirshfeld analysis is replicated (every rank holds the same density and returns the same indices).
- Arguments:
- handletype(c_ptr), value
- f_plusreal(kind=c_double), intent(out), dimension(*)
- f_minusreal(kind=c_double), intent(out), dimension(*)
- f_zeroreal(kind=c_double), intent(out), dimension(*)
- q_nreal(kind=c_double), intent(out), dimension(*)
- q_np1real(kind=c_double), intent(out), dimension(*)
- q_nm1real(kind=c_double), intent(out), dimension(*)
- Returns:
- statusinteger(kind=c_int)
trc_fukui_scheme (function)
-
function trc_fukui_scheme(handle, scheme, f_plus, f_minus, f_zero, q_n, q_np1, q_nm1) -> status Condensed Fukui indices from the atomic charges of
scheme: “hirshfeld” (trc_fukui_hirshfeld, whose header documents the three SCFs, the ion guesses, the closed-shell requirement and the restore of the handle) or “chelpg”. With “chelpg” each of the N, N+1 and N-1 densities gets its own CHELPG fit (trc_chelpg_charges, on that state’s own molecular charge) on the same grid – the grid depends on geometry and radii only – and the indices are the same combinations of the three charge sets,trc_fukui_indices. Unlike Hirshfeld’s stockholder shares, CHELPG charges are not a partition of the density difference, so a CHELPG f can be negative; the sum rule (each of f+ and f- sums to one) still holds, because the fit is constrained to the molecular charge. TRC_ERR_BADARG for any otherscheme. Same statuses and collective-call rule astrc_fukui_hirshfeld; the C ABI is unchanged.- Arguments:
- handletype(c_ptr), value
- schemecharacter(len=*), intent(in)
- f_plusreal(kind=c_double), intent(out), dimension(*)
- f_minusreal(kind=c_double), intent(out), dimension(*)
- f_zeroreal(kind=c_double), intent(out), dimension(*)
- q_nreal(kind=c_double), intent(out), dimension(*)
- q_np1real(kind=c_double), intent(out), dimension(*)
- q_nm1real(kind=c_double), intent(out), dimension(*)
- Returns:
- statusinteger(kind=c_int)
trc_mo_coefficients (function)
-
function trc_mo_coefficients(handle, cmo) -> status After a symmetric run reported in the input frame the orbitals are rotated back exactly (C_in = D C_std, trc_sym_frame).
CONTRAVARIANT under trc_set_ao_norm, on the AO (row) index only: C_out = N^-1 C_terco per spin slice when UNIT – see trc_density for why this scales a copy, not
cx%res%cmoitself.- Arguments:
- handletype(c_ptr), value
- cmoreal(kind=c_double), intent(out), dimension(*)
- Returns:
- statusinteger(kind=c_int)
trc_mo_energies (function)
-
function trc_mo_energies(handle, eps) -> status - Arguments:
- handletype(c_ptr), value
- epsreal(kind=c_double), intent(out), dimension(*)
- Returns:
- statusinteger(kind=c_int)
trc_rimp2_energy (function)
-
function trc_rimp2_energy(handle, e_os, e_ss) -> status - Arguments:
- handletype(c_ptr), value
- e_osreal(kind=c_double), intent(out)
- e_ssreal(kind=c_double), intent(out)
- Returns:
- statusinteger(kind=c_int)
trc_set_symmetry (function)
-
function trc_set_symmetry(handle, group, tol) -> status Point-group symmetry for the SCF (ABI 1.23). Off by default: a fresh context’s request is “off” (“default” is a name for it), so nothing changes until a caller asks. “on” (or “auto”) asks for the largest Abelian group of the molecule, D2h or a subgroup (symmetric and spherical tops and linear molecules use their largest Abelian subgroup), reports in the caller’s input frame and runs in C1, with one log line, where the symmetric SCF is not supported. A group name is strict, and must be the detected group or a subgroup of it (else trc_run_scf refuses).
tolis the geometry tolerance in Bohr, or 0 for the default (1e-5). With a group other than C1, trc_run_scf moves the molecule to the symmetrised, oriented standard frame and runs the SCF, and any gradient, there; trc_geometry, trc_gradient, trc_mo_coefficients, trc_density and the borrowed handles report that frame for a named group and the input frame for “on”/”auto” (trc_set_symmetry_report_frame overrides). A named group is refused at the run, not here, for: density fitting, PCM, fractional occupations, SOSCF, more than one rank, a given or projected guess, RI-MP2, CPHF/CPKS, the Hessian, Fukui indices and restarts; an on/auto request falls back to C1 there. A request longer than 32 characters is refused.- Arguments:
- handletype(c_ptr), value
- groupcharacter(kind=c_char, len=1), intent(in), dimension(*)
- tolreal(kind=c_double), value
- Returns:
- statusinteger(kind=c_int)
trc_set_symmetry_skeleton (function)
-
function trc_set_symmetry_skeleton(handle, on) -> status Under a symmetry request (trc_set_symmetry), force the Fock matrix AND the four-centre gradient to be built from the orbit representatives of the integral quartets and symmetrized (on = 1), or force the full builds and symmetrize those (on = 0); on = -1 hands the choice back to the size rule (trc_sym_run’s sym_run_skeleton_size_rule), which is also the choice without this call. Any other value is refused (TRC_ERR_BADARG). TRC_SYM_SKELETON=0/1 in the environment overrides all three. One verdict covers both builds, because both grow rather than shrink on a molecule whose every pair orbit is a singleton. The same SCF and the same gradient either way, to round-off; only the number of integrals computed differs. No effect without a group other than C1, with density fitting or over more than one rank (those take the full build).
- Arguments:
- handletype(c_ptr), value
- oninteger(kind=c_int), value
- Returns:
- statusinteger(kind=c_int)
trc_set_symmetry_report_frame (function)
-
function trc_set_symmetry_report_frame(handle, frame) -> status The frame a symmetric run reports in: the geometry (trc_geometry), the gradient, the orbitals, the density and the borrowed basis/ERI handles (trc_context_basis/eri). 1 = the caller’s input frame (the molecule symmetrised in it), 0 = the group’s standard frame, -1 = the default: the input frame when the symmetry request is the default one, the standard frame when trc_set_symmetry asked for it. Energies, orbital energies, irrep labels, occupations and atomic charges do not depend on it.
- Arguments:
- handletype(c_ptr), value
- frameinteger(kind=c_int), value
- Returns:
- statusinteger(kind=c_int)
trc_symmetry_report_frame (function)
-
function trc_symmetry_report_frame(handle, frame) -> status The frame the getters return now: 1 = the caller’s input frame (every run without symmetry, and a symmetric run reported in it), 0 = the standard frame of the group the last run used. TRC_ERR_STATE before a successful run.
- Arguments:
- handletype(c_ptr), value
- frameinteger(kind=c_int), intent(out)
- Returns:
- statusinteger(kind=c_int)
trc_set_irrep_nelec (function)
-
function trc_set_irrep_nelec(handle, spec) -> status Fix the electrons per irrep, as pyscf’s irrep_nelec: “A’=6,A”=2” for a restricted run (even counts), “A’=4/3,A”=1/1” (alpha/beta) for an unrestricted one; irreps not listed hold none. An empty string restores the aufbau occupation. The labels are checked against the group when trc_run_scf runs. A gradient is refused for occupations that differ from the aufbau ones. Set, they make an on/auto request strict (refused, never run in C1, where symmetry is not supported), whether trc_set_symmetry comes before or after. A specification longer than 256 characters is refused.
- Arguments:
- handletype(c_ptr), value
- speccharacter(kind=c_char, len=1), intent(in), dimension(*)
- Returns:
- statusinteger(kind=c_int)
trc_symmetry_group (function)
-
function trc_symmetry_group(handle, buf, buflen) -> status The point group the last trc_run_scf used (“C1” when it ran without symmetry), NUL-terminated into
bufofbuflenchars. TRC_ERR_STATE unless a symmetry request ran.- Arguments:
- handletype(c_ptr), value
- bufcharacter(kind=c_char, len=1), intent(out), dimension(*)
- bufleninteger(kind=c_int), value
- Returns:
- statusinteger(kind=c_int)
trc_symmetry_detected (function)
-
function trc_symmetry_detected(handle, buf, buflen) -> status The largest point group found in the geometry, before the cap to the groups this build supports (so “C2v” for water while only Cs is used).
- Arguments:
- handletype(c_ptr), value
- bufcharacter(kind=c_char, len=1), intent(out), dimension(*)
- bufleninteger(kind=c_int), value
- Returns:
- statusinteger(kind=c_int)
trc_symmetry_irrep_name (function)
-
function trc_symmetry_irrep_name(handle, irrep, buf, buflen) -> status The name of irrep
irrep(1-based, the order of trc_mo_irreps) of the group used. TRC_ERR_STATE unless the last run was symmetric.- Arguments:
- handletype(c_ptr), value
- irrepinteger(kind=c_int), value
- bufcharacter(kind=c_char, len=1), intent(out), dimension(*)
- bufleninteger(kind=c_int), value
- Returns:
- statusinteger(kind=c_int)
trc_symmetry_residual (function)
-
function trc_symmetry_residual(handle, residual) -> status The largest displacement (Bohr) symmetrisation made to any atom of the input geometry; 0 for C1.
- Arguments:
- handletype(c_ptr), value
- residualreal(kind=c_double), intent(out)
- Returns:
- statusinteger(kind=c_int)
trc_symmetry_frame (function)
-
function trc_symmetry_frame(handle, rot, shift) -> status The orientation of the standard frame: x_std = rot (x - shift) for an input-frame point x (Bohr).
rotis 9 doubles, row-major (rot[3*i+j]);shiftis the centre of nuclear charge, 3 doubles. The identity and zero for C1.- Arguments:
- handletype(c_ptr), value
- rotreal(kind=c_double), intent(out), dimension(*)
- shiftreal(kind=c_double), intent(out), dimension(*)
- Returns:
- statusinteger(kind=c_int)
trc_symmetry_nirrep (function)
-
function trc_symmetry_nirrep(handle, nirrep) -> status The number of irreps of the group used. TRC_ERR_STATE unless the last run was symmetric (group other than C1).
- Arguments:
- handletype(c_ptr), value
- nirrepinteger(kind=c_int), intent(out)
- Returns:
- statusinteger(kind=c_int)
trc_symmetry_irrep_dim (function)
-
function trc_symmetry_irrep_dim(handle, dim) -> status The number of symmetry-adapted basis functions of each irrep (trc_symmetry_nirrep entries), summing to trc_nao.
- Arguments:
- handletype(c_ptr), value
- diminteger(kind=c_int), intent(out), dimension(*)
- Returns:
- statusinteger(kind=c_int)
trc_mo_irreps (function)
-
function trc_mo_irreps(handle, irreps) -> status The irrep of each molecular orbital, 1-based into the irrep order of trc_symmetry_irrep_name, laid out like trc_mo_energies ((nao, nspin), column-major); 0 for an orbital canonical orthogonalisation dropped. TRC_ERR_STATE unless the last run was symmetric.
- Arguments:
- handletype(c_ptr), value
- irrepsinteger(kind=c_int), intent(out), dimension(*)
- Returns:
- statusinteger(kind=c_int)
trc_geometry (function)
-
function trc_geometry(handle, xyz) -> status The geometry the context holds now, atom-major Bohr (3*natm): the input, or after a symmetric run the symmetrised geometry in the frame the results are reported in (trc_symmetry_report_frame): the caller’s input frame by default, the group’s standard frame under an explicit trc_set_symmetry request.
- Arguments:
- handletype(c_ptr), value
- xyzreal(kind=c_double), intent(out), dimension(*)
- Returns:
- statusinteger(kind=c_int)
trc_message (function)
-
function trc_message(handle, buf, buflen) -> status The last message, NUL-terminated into
bufofbuflenchars.- Arguments:
- handletype(c_ptr), value
- bufcharacter(kind=c_char, len=1), intent(out), dimension(*)
- bufleninteger(kind=c_int), value
- Returns:
- statusinteger(kind=c_int)
trc_timing_count (function)
-
function trc_timing_count(handle, n) -> status The number of entries trc_timing lists for the context’s last run, so a caller loops index = 0 .. n-1 and never has to read an error as the end of the list. TRC_ERR_STATE before any SCF has run (or after a setter invalidated it), TRC_ERR_UNSUPPORTED if the run has more entries than the library lists (never a shortened list).
- Arguments:
- handletype(c_ptr), value
- ninteger(kind=c_int), intent(out)
- Returns:
- statusinteger(kind=c_int)
trc_timing (function)
-
function trc_timing(handle, index, name, name_len, value) -> status The stage times of the context’s last run, one named value per call, in the order the stages ran:
indexcounts from 0 up to trc_timing_count - 1,namereceives a NUL-terminated dotted name (“scf.fock_first”, “rimp2.step.cholesky”, …) inname_lenchars,valuethe seconds, or a count when the last name component starts with “n_”. A buffer of TRC_TIMING_NAME_MAX chars always suffices; a shorter one that cannot hold the name and its NUL is refused with TRC_ERR_BADARG (trc_message says the length needed), never cut. An index outside 0 .. n-1 is TRC_ERR_BADARG too. Only stages the run had are listed: “scf.” after trc_run_scf, “dft.” with a functional, “dfjk.” with density fitting, “pcm.” with a continuum, “rimp2.*” once the RI-MP2 energy step of the latest trc_run_rimp2 has run (not when a gradient took the pair energies from its amplitudes). TRC_ERR_STATE before any SCF. The times are the library’s own timers (the ones the verbose tables print): each Fock, XC and step-table timer stops after a synchronous device call or an explicit device wait. A new method adds names under its own prefix; no existing name changes.- Arguments:
- handletype(c_ptr), value
- indexinteger(kind=c_int), value
- namecharacter(kind=c_char, len=1), intent(out), dimension(*)
- name_leninteger(kind=c_int), value
- valuereal(kind=c_double), intent(out)
- Returns:
- statusinteger(kind=c_int)
trc_context_basis (function)
-
function trc_context_basis(handle, basis) -> status The basis handle inside the context: BORROWED, never destroyed by the caller, valid until the context is destroyed or the basis reset. After a symmetric run whose results are reported in the input frame (an on/auto request) it is a copy of the basis on the input-frame centres, so that it goes with trc_density, trc_mo_coefficients and trc_geometry; it is rebuilt after the geometry changes. A handle borrowed BEFORE such a run is the context’s own basis, whose centres the run moved to the standard frame. Refused (TRC_ERR_STATE) while an effective core potential is attached: a basis handle cannot carry it, so trc_scf/trc_compute_1e on it would leave the core potential out.
- Arguments:
- handletype(c_ptr), value
- basistype(c_ptr), intent(out)
- Returns:
- statusinteger(kind=c_int)
trc_context_eri (function)
-
function trc_context_eri(handle, eri) -> status The ERI context at the context’s screening threshold, built on first use. BORROWED, as trc_context_basis.
- Arguments:
- handletype(c_ptr), value
- eritype(c_ptr), intent(out)
- Returns:
- statusinteger(kind=c_int)
trc_symmetry_suppress_default (subroutine)
-
subroutine trc_symmetry_suppress_default(handle) For the geometry optimiser (a Fortran-only entry, not bind(c)): the default symmetry request runs in C1 from now on, because the optimiser moves the atoms between runs and a symmetric run would move them to its own frame. An explicit request is left alone (the caller refuses it with trc_symmetry_requested).
- Arguments:
- handletype(c_ptr), intent(in)
The RI-CCSD(T) entry points (trc_set_rccsd, trc_set_rccsd_convergence,
trc_set_rccsd_algorithm, trc_run_rccsd, trc_rccsd_energy,
trc_rccsd_dimensions; ABI 1.28, trc_rccsd_energy_parts; ABI 1.29, and
trc_check_rccsd_gradient; ABI 1.37) are
among them; Using terco as a library has an example
and the list of what each call returns.
HANDLES
Objects cross the boundary as opaque void*. Each handle is a c_ptr to a
heap-allocated Fortran derived type; the caller never sees the layout and
never allocates it. That is the same contract cuEST offers and it is what
lets the Fortran side change shape without breaking callers.
WHAT IS DELIBERATELY ABSENT
No workspace-query protocol. cuEST has one (*CreateWorkspaceQuery fills a
descriptor, the caller allocates persistent and temporary buffers and hands
them back) because a C library cannot own device memory on the caller’s
behalf without an allocator contract. We are Fortran underneath with
allocatable components and release, so the objects own their own memory.
If a caller ever needs to place that memory itself, the protocol belongs
here, at this boundary, and not in the core.
ERRORS
Status codes, not exceptions or aborts. A library that stops the process on bad input is unusable inside someone else’s SCF.
COMMUNICATORS
Every entry that takes an fcomm (trc_scf_mpi, trc_rimp2, trc_set_comm)
accepts the Fortran handle of ANY intra-communicator the caller already
has open and is willing to be collective over – not just MPI_COMM_WORLD.
-1 means one rank and no MPI, in any build. terco duplicates whatever the
handle names (MPI_Comm_dup, so every rank of it must call together) into
its own comm_t and frees only that duplicate afterwards; the caller’s own
communicator is untouched and stays open for its own use throughout. This
is what lets GAMESS hand in DDI’s compute communicator – whose data
servers sit in MPI_COMM_WORLD but never call into terco, so terco must
never wait on MPI_COMM_WORLD itself – and what will let a fragment
method hand in a per-fragment sub-communicator. See trc_build_comm.
CARTESIAN COMPONENT ORDER
Every AO-indexed array this API hands back or takes in (S/T/V, the Fock
and density matrices, multipoles, DF tensors, trc_set_guess’s density)
uses the WITHIN-SHELL Cartesian order the library was BUILT with
(TRC_CART_ORDER at compile time: lexicographic by default, or gamess).
trc_cart_order below answers which one a caller is linked against, so a
caller need not know it out of band; it is a build-wide constant, not
something that varies per handle, so it takes none.
AO NORMALISATION
Separate from the order above, and a RUNTIME choice, not a build one:
trc_set_ao_norm(handle, TRC_AO_NORM_SHELL | TRC_AO_NORM_UNIT) on a
context, default TRC_AO_NORM_SHELL (terco’s and libcint’s own convention,
so nothing changes for a caller that never calls it). TRC_AO_NORM_UNIT is
GAMESS’s: every Cartesian component individually normalised to 1. See
trc_ao_norm.F90’s header for the closed form (n = sqrt((2l-1)!! /
product over x,y,z of (2*power-1)!!), FURTHER divided by terco’s own
libcint-inherited common_fac_sp scale, which is 1 for d and up but not
for s or p – also in that header, found the hard way) and the
covariant/contravariant transform it implies – M_GAMESS = N M_terco N
for a two-AO-index matrix, D_GAMESS = N^-1 D_terco N^-1 for a density,
C_GAMESS = N^-1 C_terco (one index only: the other is an orbital label,
not an AO).
The setting lives on basis_box (propagated from a context’s own choice
by take_basis, so a handle borrowed through trc_context_basis carries
it), not only on the context, because that is the object every AO-array
entry below actually holds.
SPHERICAL BASES
A context’s orbital basis may be SPHERICAL (trc_api.F90’s
trc_basis_t%spherical, set by trc_basis_json.F90 from a JSON basis’s
own function_type, “gto_spherical” meaning yes; trc_set_force_cartesian
overrides it to Cartesian regardless). When it is, every SCF-FACING
AO-indexed entry below – trc_nao, trc_density, trc_mo_coefficients,
trc_mo_energies, trc_set_guess’s dguess, and trc_run_scf itself –
is sized at nao_sph, not the Cartesian nao; trc_nao is the single
place that size is computed (scf_space_nao) and every other entry
reads it from there, so a caller sizing its own buffers from trc_nao
never has to know which case it is in. trc_is_spherical answers
directly for a caller that wants to know anyway.
The raw-basis-handle entries (trc_compute_1e, trc_compute_multipoles,
trc_compute_df2c/df3c, capi_fock and its _many and _nosym siblings,
capi_scf/capi_scf_mpi through scf_entry) are NOT affected and stay at
the Cartesian nao of trc_basis_nao unconditionally: a basis built
through trc_basis_create* has no JSON file to ever set spherical
from, by construction (trc_api.F90’s basis_build always leaves it
.false.), so there is nothing for these entries to switch on.
RI-MP2 (trc_run_rimp2) and --df (trc_scf_df.F90) both support a
spherical orbital basis now: their three-centre tensor stays Cartesian
(every kernel does), but trc_run_rimp2 folds cx%res%cmo/eps into
that space first (rimp2_driver_mo_to_cart, zero-padded past the SCF’s own
spherical MO count – trc_rimp2_driver.F90’s own header), and --df’s
d_c/gmat_c arrive already Cartesian through trc_scf_fock.F90’s
scf_fock_to_cart/scf_fock_to_sph, which is every AO index trc_scf_df.F90 ever reads.
The AUXILIARY basis (rifit for RI-MP2, jkfit for --df) follows the
ORBITAL basis’s own convention (pyscf’s auxmol.cart = mol.cart), not
necessarily its own JSON tag – see basis_json’s and
trc_set_jkfit_json’s own comments – and is folded on its own
auxiliary (P) index inside trc_scf_df.F90/trc_rimp2_driver.F90 when
it ends up spherical.
TRC_AO_NORM_UNIT AND A SPHERICAL BASIS DO NOT COMBINE. UNIT rescales
each CARTESIAN component of a shell individually (GAMESS’s convention);
a spherical AO is already a fixed linear combination of several
Cartesian components, each with its own ratio, so “the UNIT-normalised
version of a spherical d_z2” is not a well-defined request under
anything this module implements. trc_set_ao_norm(..., TRC_AO_NORM_UNIT)
refuses if the context’s current basis is spherical, and loading a
spherical basis while UNIT mode is already set is refused the other
way, at trc_set_basis_json/trc_set_aux_json. Neither direction
silently falls back to one interpretation of the two.
EVERY entry that returns or accepts an AO-indexed array, classified:
WIRED (scales when the basis/context involved is TRC_AO_NORM_UNIT):
trc_compute_1e covariant, S and T and V each
trc_compute_multipoles covariant, one multipole component at a time
trc_density contravariant (context)
trc_mo_coefficients contravariant, AO index only (context)
trc_set_guess covariant-IN for TRC_GUESS_GIVEN, once, at the
copy (context) – see that entry’s own comment
capi_fock (trc_fock), trc_fock_many, trc_fock_nosym
dmat contravariant in, gmat covariant out. This is GAMESS’s own
MAIN caller – its Fock/J/K build, run_Fockbuild’s role in
hpcchem_driver.src – so it is wired even though it costs the
one exception to this module’s usual zero-copy Fock path: in
TRC_AO_NORM_UNIT, dmat is copied to a host scratch array and
scaled to terco’s own convention THERE (never touching the
caller’s buffer – see fock_scale_in), and gmat is scaled in
place AFTER the build, since it is terco’s own to write anyway
(fock_scale_out). One O(n^2) copy against an O(n^4) Fock build.
TRC_AO_NORM_SHELL, the default, still takes the original
sequence-associated NO-COPY path unchanged (see fock_shaped’s
own comment), so no existing caller pays anything for this.
trc_fock_many’s nd densities (density index fastest) use
their own small scale-in/out pair for that layout.
capi_scf (trc_scf), capi_scf_mpi (trc_scf_mpi), through scf_entry
dguess contravariant in, dmat contravariant out, eps invariant;
wired for the same reason as the Fock family – a UNIT-mode
caller can reach this with a context-borrowed basis exactly
as it can reach trc_fock. res%dmat/bb%cmo/bb%eps stay in
terco’s own convention internally (trc_run_rimp2 reads them
that way); only the copies handed back across the C boundary
are scaled.
INVARIANT, untouched by design (see trc_ao_norm.F90’s header for why): trc_mo_energies, trc_energy, trc_energy_parts, trc_converged, trc_iterations, trc_rimp2_energy, trc_nao, trc_nmo, trc_nspin, trc_mo_occupations (MO-indexed, like trc_mo_energies, not AO-indexed), trc_message, trc_set_pcm, trc_pcm_energy, trc_gradient, trc_polarizability, trc_dipole_moment, trc_spin_square (a nuclear-coordinate array and a Cartesian response tensor, neither an AO one – an SCF energy derivative or response does not depend on which AO normalisation convention computed it)
NOT AO-INDEXED DATA (build or borrow a HANDLE; nothing to scale here, the handle’s own ao_norm_kind is what a later entry reads): trc_basis_create*, trc_pairs_create, trc_eri_create, trc_context_basis, trc_context_eri, trc_set_ao_norm, trc_get_ao_norm
COVARIANT/CONTRAVARIANT BY THE SAME RULE, BUT NOT WIRED IN THIS RELEASE
– always behave as TRC_AO_NORM_SHELL regardless of what a context they
were reached through is set to, which is safe (identical to every
caller before this setting existed) but not yet convention-aware:
trc_compute_df2c, trc_compute_df3c
covariant, one N per AO index (df3c’s auxiliary index scales by
the AUXILIARY basis’s own N, not the orbital basis’s – it is a
basis function too, just a different basis). Unreached by
trc_set_ao_norm in practice: context never lends out ab (no
trc_context_aux exists), so every aux handle these two ever see
was built by trc_basis_create* directly and is always
TRC_AO_NORM_SHELL.
Fortran only (no bind(c), not in terco.h): the geometry optimiser’s own up-front gradient check.