API Documentation
qcmanybody.ManyBodyCore
ManyBodyCore(molecule: Molecule, bsse_type: Sequence[BsseEnum], levels: Mapping[Union[int, Literal['supersystem']], str], *, return_total_data: bool, supersystem_ie_only: bool, embedding_charges: Mapping[int, Sequence[float]])
Source code in qcmanybody/core.py
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 |
|
format_calc_plan
Formulate per-modelchem and per-body job count data and summary text.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
sset |
str
|
Among {"all", "nocp", "cp", "vmfc_compute"}, which data structure to return. |
'all'
|
Returns:
Type | Description |
---|---|
info
|
A text summary with per- model chemistry and per- n-body-level job counts.
|
Dict[str, Dict[int, int]]
|
Data structure with outer key mc-label, inner key 1-indexed n-body, and value job count. |
Source code in qcmanybody/core.py
173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 |
|
iterate_molecules
Iterate over all the molecules needed for the computation.
Yields model chemistry, label, and molecule.
Source code in qcmanybody/core.py
229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 |
|
analyze
Parameters:
Name | Type | Description | Default |
---|---|---|---|
component_results |
Dict[str, Dict[str, Union[float, ndarray]]]
|
Nested dictionary with results from all individual molecular system calculations, including all subsystem/basis combinations, all model chemistries, and all properties (e.g., e/g/h). For example, the below is the format for a nocp gradient run on a
helium dimer with 1-body at CCSD and 2-body at MP2. The outer string
key can be generated with the
|
required |
Source code in qcmanybody/core.py
512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 |
|
qcmanybody.ManyBodyComputer
Bases: BaseComputerQCNG
from_manybodyinput
classmethod
from_manybodyinput(input_model: ManyBodyInput, build_tasks: bool = True)
Source code in qcmanybody/computer.py
387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 |
|
ManyBodyComputer
key | type | required | description | default |
---|---|---|---|---|
input_data | True | Input schema containing the relevant settings for performing the many body expansion. This is entirely redundant with the piecemeal assembly of this Computer class and is only stored to be available for error handling and exact reconstruction of ManyBodyResult. | None | |
bsse_type | False | Requested BSSE treatments. First in list determines which interaction or total energy/gradient/Hessian returned. | [ |
|
molecule | True | Target molecule for many body expansion (MBE) or interaction energy (IE) analysis. Fragmentation should already be defined in fragments and related fields. |
None | |
driver | True | The computation driver; i.e., energy, gradient, hessian. In case of ambiguity (e.g., MBE gradient through finite difference energies or MBE energy through composite method), this field refers to the target derivative, not any means specification. | None | |
embedding_charges | typing.List[float] | False | Atom-centered point charges to be used to speed up nbody-level convergence. Charges are placed on molecule fragments whose basis sets are not included in the computation. (An implication is that charges aren't invoked for bsse_type=cp.) Keys: 1-based index of fragment. Values: list of atom charges for that fragment. | None |
return_total_data | False | When True, returns the total data (energy/gradient/Hessian) of the system, otherwise returns interaction data. Default is False for energies, True for gradients and Hessians. Note that the calculation of counterpoise corrected total energies implies the calculation of the energies of monomers in the monomer basis, hence specifying return_total_data = True may carry out more computations than return_total_data = False . For gradients and Hessians, return_total_data = False is rarely useful. |
None | |
levels | False | Dictionary of different levels of theory for different levels of expansion. Note that the primary method_string is not used when this keyword is given. supersystem computes all higher order n-body effects up to the number of fragments; this higher-order correction uses the nocp basis, regardless of bsse_type. A method fills in for any lower unlisted nbody levels. Note that if both this and max_nbody are provided, they must be consistent. Examples: SUPERSYSTEM definition suspect* {1: 'ccsd(t)', 2: 'mp2', 'supersystem': 'scf'} * {2: 'ccsd(t)/cc-pvdz', 3: 'mp2'} * Now invalid: {1: 2, 2: 'ccsd(t)/cc-pvdz', 3: 'mp2'} Examples above are processed in the ManyBodyComputer, and once processed, only the values should be used. The keys turn into nbodies_per_mc_level, as notated below. * {1: 'ccsd(t)', 2: 'mp2', 'supersystem': 'scf'} -> nbodies_per_mc_level=[[1], [2], ['supersystem']] * {2: 'ccsd(t)/cc-pvdz', 3: 'mp2'} -> nbodies_per_mc_level=[[1, 2], [3]] |
None | |
max_nbody | False | Maximum number of bodies to include in the many-body treatment. Possible: max_nbody <= nfragments. Default: max_nbody = nfragments. | None | |
supersystem_ie_only | False | Target the supersystem total/interaction energy (IE) data over the many-body expansion (MBE) analysis, thereby omitting intermediate-body calculations. When False (default), compute each n-body level in the MBE up through max_nbody . When True (only allowed for max_nbody = nfragments ), only compute enough for the overall interaction/total energy: max_nbody-body and 1-body. When True, properties INTERACTION {driver} THROUGH {max_nbody}-BODY will always be available; TOTAL {driver} THROUGH {max_nbody}-BODY will be available depending on return_total_data ; and {max_nbody}-BODY CONTRIBUTION TO {driver} won't be available (except for dimers). This keyword produces no savings for a two-fragment molecule. But for the interaction energy of a three-fragment molecule, for example, 2-body subsystems can be skipped with supersystem_ie_only=True . Do not use with vmfc in bsse_type as it cannot produce savings. |
False | |
task_list | typing.Any | False | {} | |
qcmb_core | typing.Any | False | Low-level interface | None |
qcmanybody.utils
all_same_shape
Check if all elements of an iterable have the same shape.
Source code in qcmanybody/utils.py
49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
|
resize_gradient
resize_gradient(grad: ndarray, bas: Tuple[int, ...], fragment_size_dict: Dict[int, int], fragment_slice_dict: Dict[int, slice], *, reverse: bool = False) -> ndarray
Pads or extracts a gradient array between subsystem and full supersystem sizes.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
grad |
ndarray
|
Gradient matrix of natural size for bas, (3 * <nat in bas>, 3).
If |
required |
bas |
Tuple[int, ...]
|
1-indexed fragments active in grad.
If |
required |
fragment_size_dict |
Dict[int, int]
|
Dictionary containing the number of atoms of each 1-indexed fragment.
For He--HOOH--Me cluster, |
required |
fragment_slice_dict |
Dict[int, slice]
|
Dictionary containing slices that index the gradient matrix for each of the 1-indexed fragments.
For He--HOOH--Me cluster, |
required |
reverse |
bool
|
If True, contract grad from supersystem size and shape to that which is natural for bas. |
False
|
Returns:
Type | Description |
---|---|
ndarray
|
Gradient array padded with zeros to supersystem size, (3 * <nat of supersystem>, 3). If reverse=True, gradient array extracted to natural size, (3 * <nat in bas>, 3). |
Source code in qcmanybody/utils.py
65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 |
|
resize_hessian
resize_hessian(hess: ndarray, bas: Tuple[int, ...], fragment_size_dict: Dict[int, int], fragment_slice_dict: Dict[int, slice], *, reverse: bool = False) -> ndarray
Pads or extracts a Hessian array between subsystem and full supersystem sizes.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
hess |
ndarray
|
Hessian matrix of natural size for bas, (3 * <nat in bas>, 3 * <nat in bas>).
If |
required |
bas |
Tuple[int, ...]
|
1-indexed fragments active in hess.
If |
required |
fragment_size_dict |
Dict[int, int]
|
Dictionary containing the number of atoms of each 1-indexed fragment.
For He--HOOH--Me cluster, |
required |
fragment_slice_dict |
Dict[int, slice]
|
Dictionary containing slices that index the gradient matrix for each of the 1-indexed fragments.
For He--HOOH--Me cluster, |
required |
reverse |
bool
|
If True, contract hess from supersystem size and shape to that which is natural for bas. |
False
|
Returns:
Type | Description |
---|---|
ndarray
|
Hessian array padded with zeros to supersystem size, (3 * <nat of supersystem>, 3 * <nat of supersystem>). If reverse=True, Hessian array extracted to natural size, (3 * <nat in bas>, 3 * <nat in bas>). |
Source code in qcmanybody/utils.py
117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 |
|
sum_cluster_data
sum_cluster_data(data: Dict[str, Union[float, ndarray]], compute_list: Set[FragBasIndex], mc_level_lbl: str, vmfc: bool = False, nb: int = 0) -> Union[float, ndarray]
Sum (direct or alternate weight by n-body) like data from
Parameters:
Name | Type | Description | Default |
---|---|---|---|
data |
Dict[str, Union[float, ndarray]]
|
Dictionary containing computed property (e/g/H/etc.) for each subsystem/component computation. |
required |
compute_list |
Set[FragBasIndex]
|
A list of (frag, bas) tuples notating all the required computations for the desired sum. |
required |
mc_level_lbl |
str
|
User label for what modelchem level results should be pulled out of data. |
required |
vmfc |
bool
|
Is this a vmfc calculation, by default False? |
False
|
nb |
int
|
1-indexed n-body level only used when |
0
|
Returns:
Type | Description |
---|---|
Union[float, ndarray]
|
Scalar or array containing summed energy, gradient, Hessian, or other result.
Usually (nocp or cp; |
Raises:
Type | Description |
---|---|
ValueError
|
If the shapes of all the |
Source code in qcmanybody/utils.py
180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 |
|
labeler
labeler(mc_level_lbl: Optional[Union[str, int]], frag: Tuple[int, ...], bas: Tuple[int, ...], *, opaque: bool = True) -> str
Form label from model chemistry id and fragment and basis indices.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
mc_level_lbl |
Optional[Union[str, int]]
|
Key identifying the model chemistry. May be |
required |
frag |
Tuple[int, ...]
|
List of 1-indexed fragments active in the supersystem. |
required |
bas |
Tuple[int, ...]
|
List of 1-indexed fragments with active basis sets in the supersystem. All those in frag plus any ghost. |
required |
opaque |
bool
|
Toggle whether to return JSON-friendly semi-opaque internal str label (True) or eye-friendly label with @ for basis and § for model chemistry (False). |
True
|
Returns:
Type | Description |
---|---|
str
|
JSON string from inputs:
|
Source code in qcmanybody/utils.py
246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 |
|
delabeler
Back-form from label into tuple.
Returns:
Type | Description |
---|---|
mcfragbas
|
Tuple of opaque or pretty-print model chemistry (may be None for latter), fragments and bases (1-indexed by convention).
|
Source code in qcmanybody/utils.py
292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 |
|
print_nbody_energy
print_nbody_energy(energy_body_dict: Mapping[int, float], header: str, nfragments: int, modelchem_labels, embedding: bool, supersystem_ie_only: bool, supersystem_beyond: Optional[int]) -> str
Format summary string for energies of a single bsse_type. Logs and returns output.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
energy_body_dict |
Mapping[int, float]
|
Input data. |
required |
header |
str
|
Specialization for table title. |
required |
nfragments |
int
|
Number of lines in table is number of fragments. |
required |
modelchem_labels |
Dictionary mapping active nbody-levels to a tuple with first element the
full model chemistry key and second element a short label. A suitable
dictionary is |
required | |
embedding |
bool
|
Whether charge embedding present suppress printing, usually False |
required |
supersystem_ie_only |
bool
|
Whether only 1-body and nfragments-body levels are available, usually False. |
required |
supersystem_beyond |
Optional[int]
|
If not None, the number of nbody-levels computed by MBE explicitly. Beyond this gets supersystem SS label. |
required |
Returns:
Type | Description |
---|---|
str
|
A text table in Hartrees and kcal/mol
|
Source code in qcmanybody/utils.py
321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 |
|
collect_vars
collect_vars(bsse: str, prop: str, body_dict: Mapping[int, Union[float, ndarray]], max_nbody: int, embedding: bool = False, supersystem_ie_only: bool = False, has_supersystem: bool = False) -> Dict
From body_dict, construct data for ManyBodyResultProperties.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
bsse |
str
|
Label for a single many-body treatment, generally a value of BsseEnum. |
required |
prop |
str
|
Label for a single property, generally a value of DriverEnum. |
required |
body_dict |
Mapping[int, Union[float, ndarray]]
|
Dictionary of minimal per-body info already specialized for property prop and treatment bsse. May contain either total data or interaction data (cummulative, not additive) from 1-body to max_nbody-body (see also supersystem_ie_only). Interaction data signaled by zero float or array for 1-body. May contain data from multiple model chemistry levels. |
required |
max_nbody |
int
|
description |
required |
embedding |
bool
|
Is charge embedding enabled, by default False? |
False
|
supersystem_ie_only |
bool
|
Is data available in body_dict only for 1-body (possibly zero) and nfr-body levels? By default False: data is available for consecutive levels, up to max_nbody-body. |
False
|
has_supersystem |
bool
|
Whether contributions higher than max_nbody are a summary correction. |
False
|
Returns:
Type | Description |
---|---|
dict
|
description. Empty return if embedding enabled. |
Source code in qcmanybody/utils.py
419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 |
|
provenance_stamp
Return dictionary satisfying QCSchema,
https://github.com/MolSSI/QCSchema/blob/master/qcschema/dev/definitions.py#L23-L41
with QCManyBody's credentials for creator and version. The
generating routine's name is passed in through routine
.
qcmb.utils.provenance_stamp(__name__)
#> {'creator': 'QCManyBody', 'version': '0.2.2', 'routine': '__main__'}
Source code in qcmanybody/utils.py
506 507 508 509 510 511 512 513 514 515 516 517 518 519 |
|
translate_qcvariables
Translate between ManyBody results in Psi4/QCDB terminology (qcvars) and QCSchema terminology (skprops).
Parameters:
Name | Type | Description | Default |
---|---|---|---|
varsmap |
Mapping[str, Any]
|
Dictionary with keys all members of QCVariables or ManyBodyResultProperties and arbitrary values. |
required |
Returns:
Type | Description |
---|---|
dict
|
varsmap with keys swapped to other set. Untranslatable keys are omitted. |
Source code in qcmanybody/utils.py
522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 |
|
modelchem_labels
modelchem_labels(nb_per_mc: Dict[str, List[Union[int, Literal['supersystem']]]], presorted: bool = False) -> Dict[Union[int, Literal['supersystem']], Tuple[str, str, str]]
Form ordinal and letter labels for model chemistries.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
nb_per_mc |
Dict[str, List[Union[int, Literal['supersystem']]]]
|
Dictionary mapping model chemistries to lists of n-body levels computed.
If a model chemistry is supersystem, the value should be ["supersystem"].
Generally, this is the |
required |
presorted |
bool
|
If True, the input dictionary keys and values are already sorted by increasing n-body level.
This is the case when the input is |
False
|
Returns:
Type | Description |
---|---|
mc_per_nb
|
Dictionary mapping n-body levels to a tuple of full model chemistry label, single-letter ordinal label, and n-body-levels-covered label.
|
Source code in qcmanybody/utils.py
545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 |
|
qcmanybody.builder
build_nbody_compute_list
build_nbody_compute_list(bsse_type: Iterable[BsseEnum], nfragments: int, nbodies: Iterable[Union[int, Literal['supersystem']]], return_total_data: bool, supersystem_ie_only: bool, supersystem_max_nbody: Optional[int] = None) -> Dict[str, Dict[int, Set[FragBasIndex]]]
Generates lists of N-Body computations needed for requested BSSE treatments.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
bsse_type |
Iterable[BsseEnum]
|
Requested BSSE treatments. |
required |
nfragments |
int
|
Number of distinct fragments comprising the full molecular supersystem. |
required |
nbodies |
Iterable[Union[int, Literal['supersystem']]]
|
List of n-body levels (e.g., |
required |
return_total_data |
bool
|
Whether the total data (True; energy/gradient/Hessian) of the molecular system has been requested, as opposed to interaction data (False). |
required |
supersystem_ie_only |
bool
|
Target the supersystem total/interaction energy (IE) data over the many-body expansion (MBE) " analysis, thereby omitting intermediate-body calculations. |
required |
supersystem_max_nbody |
Optional[int]
|
Maximum n-body to use for a supersystem calculation. Must be specified if "supersystem" is in |
None
|
Returns:
Type | Description |
---|---|
compute_dict
|
Dictionary containing subdicts enumerating compute lists for each possible BSSE treatment.
Subdict keys are n-body levels and values are sets of all the
Subdicts below are always returned. Any may be empty if not requested through bsse_type.
|
Source code in qcmanybody/builder.py
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 |
|