Zemax import: glass resolution#
load_zemax_file("design.zmx") resolves each glass the way OpticStudio
does: from the catalogs the file declares on its GCAT line, by exact name.
It never falls back to a fuzzy search across every catalog in the material
database, so an imported lens gets the glass the file asks for or a model of
it, never a different glass with a similar name.
Resolution order#
For each GLAS <name> <solve> <?> <nd> <vd> ... line:
Model glasses. A solve type of
1or the name___BLANKmarks an explicit model glass. It becomes anAbbeMaterialbuilt from nd/vd, without searching the catalogs.Declared catalogs, exact name. Every
GCATcatalog is searched for the exact name (case insensitive), withMaterial(name, catalog=..., match_policy="strict").Found in one catalog: that glass is used.
Found in several: the glass whose nd/vd best match the
GLASline is used, and the first catalog inGCATorder wins a tie or a line without nd/vd. A.zmxfile lists catalogs once for the whole file, so nd/vd are what tell, for example, Schott F2 from CDGM F2 on a given surface.
MIL-number names. A six-digit name such as
517642(or517.642) that no catalog contains is a model glass with nd = 1.517 and vd = 64.2, taken from the name.Not found. Any other glass becomes an
AbbeMaterialfrom the nd/vd on theGLASline, and anOptilandMaterialWarningnames the surface and glass. If the line has no nd/vd, import fails withValueError.
A glass modelled with vd = 0 is undispersed and becomes an IdealMaterial.
A GCAT catalog that is not in the material database (see
MaterialRegistry.instance().list_catalogs()) is skipped with a warning, so
its glasses are modelled from nd/vd. A file without GCAT models every
glass.
Glasses from AGF catalogs#
OpticStudio evaluates each glass from its AGF catalog entry: the dispersion
formula code and the coefficients on its CD line. The material database
holds refractiveindex.info data instead, which can differ in fit, wavelength
range or catalog edition, and it has no vendor, custom or in-house catalogs.
To use the AGF files you already have, pass the folders that hold them:
from optiland.fileio import load_zemax_file
optic = load_zemax_file("design.zmx", agf_dirs=["C:/Users/me/Documents/Zemax/Glasscat"])
or list them in the OPTILAND_AGF_PATH environment variable, separated as
in PATH. With AGF folders, step 2 above changes for each GCAT
catalog that has an AGF file (SCHOTT as SCHOTT.AGF, ignoring case):
The catalog is searched in its AGF file by exact name (case insensitive), not in the material database, and a glass found there becomes an
AGFMaterial. A glass the AGF file lacks is not looked up in the database’s catalog of the same name; it goes on to steps 3 and 4, as in OpticStudio.A catalog without an AGF file uses the material database as before.
When the folders hold the same catalog more than once, the first folder wins.
agf_dirs=[] switches the AGF lookup off even when OPTILAND_AGF_PATH
is set. Without AGF folders, glasses resolve exactly as described above.
Optiland ships no AGF data.
What changed#
Earlier versions fell back to Material(name), which searches every catalog
with substring and edit-distance matching. Some files now resolve to a
different material:
|
Before |
Now |
|---|---|---|
|
The BaF2 crystal ( |
Model glass from nd/vd, with a warning |
|
|
Model glass from nd/vd, with a warning |
|
|
Model glass from nd/vd, with a warning |
Glasses that a declared catalog contains under their exact name resolve as
before. Material(name) itself is unchanged; only the Zemax importer
resolves strictly.
Export#
save_zemax_file writes the catalog of each Material and
AGFMaterial to GCAT and records nd/vd on every GLAS line, so a
saved file reloads to the same glasses. A Material created without a reference exports the glass catalog
it resolved to.