Skip to content

Scalar fields, difference density, and isosurfaces

Density loading is opt-in. Standard FCF or observed-intensity/IAM maps use the green/red colours; explicitly configured or self-described custom coefficient columns are treated as deformation density and use light blue/orange. The periodic Fourier grid is retained when display or symmetry-growth settings change.

The options split into four groups by responsibility:

  • differenceDensity — source-specific calculation settings (input mode, reflection reading, IAM, corrections, FFT grids).
  • scalarField — the shared worker policy.
  • isosurface — 3D mesh presentation (contour level, colours, resolution, progressive steps, symmetry reuse).
  • contourLines — planar line sections.

Narrative documentation: General → Density concepts and Library → Density maps (which also covers custom coefficient columns and anomalous correction layouts in detail).

OptionTypeDefaultDescription
differenceDensity.autoLoadBooleanfalseAfter installing the structure, automatically start density work from the loaded CIF.
differenceDensity.inputModeString"auto"auto, fcf, or cif-iam. Auto prefers explicit Fourier coefficients and otherwise uses observed intensities plus IAM phases.
differenceDensity.reflectionsObject{}Reflection-reader configuration; see the rows below.
differenceDensity.reflections.sourceString"auto"auto, refln, diffrn_refln, or shelx_hkl_file.
differenceDensity.reflections.mergeFriedelBooleanautomaticMerges Friedel pairs for normal-scattering IAM maps; anomalous IAM defaults to keeping them separate.
differenceDensity.reflections.removeSystematicAbsencesBooleantrueRemoves absent unmerged reflections before symmetry merging.
differenceDensity.reflections.absenceToleranceNumber1e-8Complex general-position phase-sum tolerance used for absence detection.
differenceDensity.iamObject{}Independent-atom structure-factor configuration; see the rows below.
differenceDensity.iam.includeAnomalousBooleanfalseIncludes f′ and f″ in IAM factors. Difference maps use normal scattering unless explicitly enabled.
differenceDensity.iam.wavelengthNumberFallback wavelength in Å; a wavelength reported by the CIF takes precedence.
differenceDensity.iam.cromerMannObjectFallback nine-coefficient Cromer–Mann arrays keyed by atom type or element; complete CIF rows take precedence.
differenceDensity.iam.dispersionValuesObjectFallback f′/f″ values keyed by atom type or element; site and type CIF values take precedence.
differenceDensity.iam.anomalous.tableStringautomaticForces the internal Cu or Mo dispersion table.
differenceDensity.iam.anomalous.wavelengthToleranceNumber0.005 ÅControls automatic wavelength matching against the internal tables.
differenceDensity.intensityScaleNumber|nullnullExplicit observed-to-IAM intensity scale; null fits a positive scale from the reflections.
differenceDensity.extinctionCorrectionString|Boolean|Number|Object"auto"Corrects observed amplitudes for a reported SHELXL isotropic EXTI model. Accepts auto, true/false, a coefficient, or a configuration object.
differenceDensity.extinctionCorrection.coefficientNumberOverrides the CIF extinction coefficient when the option is an object.
differenceDensity.extinctionCorrection.wavelengthNumberOverrides the extinction-model wavelength when the option is an object.
differenceDensity.coefficientColumnsObject|nullnullCustom loop/index columns and either amplitude/phase or direct A/B columns. Any custom definition is displayed as deformation density.
differenceDensity.coefficientColumns.loopString"_refln"Custom loop category name.
differenceDensity.coefficientColumns.h / .k / .lStringMiller-index column names; default to the standard index columns of the loop.
differenceDensity.coefficientColumns.amplitudes / .phasesString or String[]One or two amplitude columns with one common phase or matching split phases.
differenceDensity.coefficientColumns.a / .bString or String[]One or two direct real/imaginary crystallographic coefficient columns; use instead of amplitudes/phases.
differenceDensity.coefficientColumns.phaseUnitString"degrees"degrees or radians.
differenceDensity.coefficientColumns.omitF000BooleanfalseOmits the mean term. Custom/deformation coefficients retain it by default.
differenceDensity.anomalousDispersionBoolean|ObjectfalseOptional anomalous-contribution correction and phase/Friedel detection.
differenceDensity.anomalousDispersion.targetStringsource-dependentfirst, second, both, or result. Custom coefficients default to first; FCF4 to both.
differenceDensity.anomalousDispersion.phaseDetectionBooleantrueEnables exact inversion/Friedel phase tests. Set false for deliberate deformation coefficients.
differenceDensity.anomalousDispersion.phaseToleranceDegreesNumber0.05°Phase tolerance of the inversion/Friedel tests.
differenceDensity.anomalousDispersion.friedelAmplitudeToleranceRelativeNumber1e-4Relative amplitude tolerance of the Friedel tests.
differenceDensity.anomalousDispersion.generatorString"auto"auto, olex, or shelxl; normally inferred from CIF metadata.
differenceDensity.anomalousDispersion.wavelength / .table / .wavelengthToleranceNumber / String / NumberFallback wavelength, optional forced Cu/Mo table, and automatic table-matching tolerance (default 0.005 Å). The CIF wavelength wins.
differenceDensity.anomalousDispersion.valuesObjectFallback f′/f″ values keyed by atom type or element; site/type CIF values take precedence.
differenceDensity.reciprocalResolutionNumber1Fraction of the available reciprocal resolution included in the Fourier map, in (0, 1].
differenceDensity.initialGridOversamplingNumber1FFT-grid oversampling used for the first progressive display.
differenceDensity.gridOversamplingNumber2Final real-space FFT-grid oversampling factor.
scalarField.useWorkerBooleantrueParse and calculate scalar fields in a Web Worker when available. Applies to reflection and Cube sources; in planar-line mode the worker also performs plane sampling and Marching Squares before transferring packed endpoints.
isosurface.useSymmetryBooleantrueReuses meshes for exactly symmetry-equivalent disconnected regions; intersecting masks remain one field to avoid seams.
isosurface.progressiveStepsArray[0.5, 0.75, 1]Ordered surface-resolution fractions emitted after the map is available; 1 is always included.
isosurface.visibleBooleantrueInitial density-surface visibility. Changing only this option toggles the retained meshes without recalculation.
isosurface.sigmaLevelNumber3Positive and negative contour magnitude in map standard deviations.
isosurface.radiusNumber1.5Cartesian clipping radius around displayed atoms, in Å.
isosurface.resolutionNumber64Minimum marching-cubes resolution.
isosurface.gridSpacingNumber0.15Target Cartesian surface-grid spacing in Å used to increase resolution for larger displayed regions.
isosurface.maxResolutionNumber96Upper bound for draw-size-dependent marching-cubes resolution.
isosurface.stitchToleranceNumber0.0001Cartesian tolerance used while welding reused surface patches.
isosurface.positiveColorColor"#267e47"Positive standard difference-density colour.
isosurface.negativeColorColor"#992a3e"Negative standard difference-density colour.
isosurface.deformationPositiveColorColor"#4FC3F7"Positive custom/deformation-density colour.
isosurface.deformationNegativeColorColor"#FF9800"Negative custom/deformation-density colour.
isosurface.opacityNumber0.55Surface opacity.
isosurface.wireframeBooleantrueDraws density surfaces as wireframes.
isosurface.maxPolyCountNumber100000Maximum marching-cubes polygon allocation per generated field.
contourLines.enabledBooleanfalseReplaces the 3D isosurface with line-only contours on a plane. It creates no plane fill/background, preserving the viewer or widget background.
contourLines.planeObject{mode: "best-fit"}Plane definition. Use {mode: "best-fit"}, {atoms: ["C1","C2","O1"]}, the string "best-fit", an atom-label array, or an explicit coordinateSystem/origin/normal definition (see below). Explicit atom lists require three non-collinear atoms; best-fit mode uses a stable crystallographic fallback for one- or two-atom structures.
contourLines.plane.coordinateSystem / .origin / .normalString / Number[] / Number[]Explicit cartesian (Å) or fractional plane. Origin and normal are three-value vectors; a fractional normal is transformed as a reciprocal/covector normal.
contourLines.plane.boundsObjectOptional in-plane {u:[min,max], v:[min,max]} bounds in Å; otherwise automatic padding around all displayed atoms is used.
contourLines.paddingNumber1.5Automatic in-plane padding around all displayed atoms, in Å.
contourLines.maxAtomDistanceNumber|null2.5Discards samples farther than this distance from any displayed atom, in Å, keeping the drawn contours from spanning empty space. Null or a negative value keeps the unclipped padded rectangle.
contourLines.resolutionNumber256Minimum samples per in-plane axis.
contourLines.gridSpacingNumber0.04Target Cartesian sample spacing in Å.
contourLines.maxResolutionNumber512Per-axis sample cap.
contourLines.interpolationString"tricubic"tricubic uses smooth slope-limited monotone sampling of the retained scalar grid without introducing local overshoot; linear uses its original trilinear sampler.
contourLines.contourCountNumber20Number of regularly spaced contour lines.
contourLines.contourStepNumber|nullnullOptional absolute contour step; takes precedence over contourCount.
contourLines.levelSubdivisionsNumber4Line intervals fitted within the ordinary field/isosurface level. A 3σ field level starts at 0.75σ by default.
contourLines.levelsNumber[]|nullnullExplicit positive contour magnitudes; takes precedence over count and step.
contourLines.signString|nullnullpositive, negative, or both; null follows the scalar-field source metadata.
contourLines.zeroLineBooleanfalseDraws an optional zero contour.
contourLines.zeroColorColor"#666666"Colour of the zero contour.
contourLines.lineColorColor|nullnullOverrides both signed line colours. Null inherits the standard/deformation positive and negative colours from isosurface.
contourLines.lineWidthNumber1.5Screen-space line width in pixels.
contourLines.haloColorColor"#ffffff"Colour of the outline drawn behind each contour line for legibility over the structure.
contourLines.haloWidthNumber1Additional screen-space width in pixels on each side of a contour line for its halo outline. Zero or a negative value disables the halo.
contourLines.opacityNumber1Contour line opacity.
contourLines.depthOffsetNumber0.02Offset along the plane normal in Å to reduce overlap artefacts.

Common per-source collection options

These accompany individual loads (loadDifferenceDensity, loadCube, addScalarField) and entries of loadScalarFieldSources; they are per-call options, not part of the defaults object above.

OptionTypeDescription
fieldIdStringStable collection identifier. Reusing it updates the existing entry instead of appending a duplicate. Default: generated.
fieldNameStringHuman-readable source name exposed by collection metadata and events.
activateBooleanWhether to display the entry as it loads. Default: true for individual loads; last entry for loadScalarFieldSources.

loadCube options

OptionTypeDescription
propertyStringdensity, signed-density, orbital, potential, or generic. Controls unit conversion, label, default contour, and whether one or both signs are drawn. Default: "density".
levelNumberAbsolute Cube contour level. Electron density defaults to 0.3 e/ų; signed density defaults to 0.05 e/ų; other properties default to three map standard deviations.
datasetIndexIntegerZero-based dataset/orbital selection for a multi-dataset Cube. Default: 0.
valueScaleNumberExplicit scalar-value multiplier. By default, Bohr-based density properties are converted from e/bohr³ to e/ų and other properties remain unscaled.
displayLabel, quantityName, valueUnitStringPresentation metadata for generic, potential, and orbital fields. These values are emitted in density display events so the UI need not inspect the map.
periodicBooleanControls cell wrapping. Default: true.
signStringpositive, negative, or both surface signs. Default: property-dependent.