autolens.analysis.model_util.mass_field_from#
- mass_field_from(lens, shear=True, mass_sheet=False, potential=False, redshift=None)[source]#
Build the
af.Model(al.MassField, ...)describing the tidal field of everything outside the modelled system, with its geometry tied to a lens galaxy model.The external field is composed of the components no galaxy owns — an
ExternalShear, aMassSheet, anExternalPotential— and is placed in a model’sfieldscollection rather than bolted onto a galaxy:lens = af.Model(al.Galaxy, redshift=0.5, mass=af.Model(al.mp.Isothermal)) model = af.Collection( galaxies=af.Collection(lens=lens, source=source), fields=af.Collection(field=al.model_util.mass_field_from(lens=lens)), )
For a single field,
fields=al.model_util.mass_field_from(lens=lens)is also supported. This shortens prior paths (fields.shear.gamma_1instead offields.field.shear.gamma_1), so the two forms have different result identifiers by design. The collection form above remains the primary example and retains its existing identifier.The
MassSheetandExternalPotentialhave a meaningful centre (unlike anExternalShear, whose deflection field is constant), and that centre is physically the centre of the system the field is expanded about. It is therefore shared with the lens galaxy’s mass centre — the same prior object, not a copy — so the two move together in the non-linear search and cost no extra dimensions.In a multi-deflector system,
lensis the primary deflector: the galaxy whose centre the external expansion is about. Pass that galaxy’s model, not a secondary one.The galaxy-attached form (
af.Model(al.Galaxy, ..., shear=af.Model(al.mp.ExternalShear))) remains fully supported and is not deprecated; this is a second way to write the same physics, one which keeps the external field out of the galaxy.- Parameters:
lens (
Model) – Theaf.Modelof the (primary) lens galaxy. Itsmass.centreis shared with the field’s centred components and, unlessredshiftis given, its redshift is the field’s redshift.shear (
bool) – If True (default), the field includes anExternalShear.mass_sheet (
bool) – If True, the field includes aMassSheet, centred on the lens mass.potential (
bool) – If True, the field includes anExternalPotential, centred on the lens mass.redshift (
Optional[float]) – The redshift of the field. Defaults to the lens galaxy model’s redshift.
- Returns:
The
af.Modelof theMassField, to be placed in the model’sfieldscollectionor supplied directly as
fieldsfor a single field.