tmmcore 0.3.1 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +2 -2
- package/src/phase.js +9 -3
- package/src/tmmWasm.js +931 -839
- package/src/tmm_kernel.c +97 -27
- package/src/tmm_kernel.wasm +0 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "tmmcore",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.0",
|
|
4
4
|
"description": "Transfer-matrix method for multilayer thin-film optics, with exact analytic derivatives and phase dispersion. JavaScript, C and WebAssembly.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./src/index.js",
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
"test": "node tests/equivalence.mjs && node tests/growing_equivalence.mjs && node tests/growing_eval_equivalence.mjs && node tests/absorbing_incident.mjs",
|
|
24
24
|
"compare": "node benchmarks/compare.mjs",
|
|
25
25
|
"examples": "node examples/01-single-layer.mjs && node examples/02-ar-coating.mjs && node examples/03-metal-mirror.mjs && node examples/04-refine.mjs && node examples/05-angle-map.mjs && node examples/06-needle.mjs && node examples/07-jacobian-map.mjs && node examples/08-group-delay.mjs",
|
|
26
|
-
"build:wasm": "emcc src/tmm_kernel.c -O3 --no-entry -sSTANDALONE_WASM=1 -sALLOW_MEMORY_GROWTH=1 -sEXPORTED_FUNCTIONS=_tmm_one,_tmm_spectrum,_tmm_jacobian,_tmm_needle_scan,_tmm_hessian,_tmm_phase_one,_tmm_phase_spectrum,_tmm_phase_jacobian,_tmm_monitor_curve,_tmm_deposition_spectra,_tmm_growing_eval_create,_tmm_growing_eval_set_top,_tmm_growing_eval_sample,_tmm_growing_eval_free,_malloc,_free -o src/tmm_kernel.wasm",
|
|
26
|
+
"build:wasm": "emcc src/tmm_kernel.c -O3 --no-entry -sSTANDALONE_WASM=1 -sALLOW_MEMORY_GROWTH=1 -sEXPORTED_FUNCTIONS=_tmm_one,_tmm_spectrum,_tmm_jacobian,_tmm_needle_scan,_tmm_hessian,_tmm_phase_one,_tmm_phase_spectrum,_tmm_phase_jacobian,_tmm_phase_jacobian_spectrum,_tmm_monitor_curve,_tmm_deposition_spectra,_tmm_growing_eval_create,_tmm_growing_eval_set_top,_tmm_growing_eval_sample,_tmm_growing_eval_free,_malloc,_free -o src/tmm_kernel.wasm",
|
|
27
27
|
"build:native": "cc -std=c99 -pedantic -Wall -Wextra -O2 -c src/tmm_kernel.c -o tmm_kernel.o"
|
|
28
28
|
},
|
|
29
29
|
"keywords": [
|
package/src/phase.js
CHANGED
|
@@ -430,14 +430,17 @@ export function coefficientPhaseDispersion(coefficientJet) {
|
|
|
430
430
|
*/
|
|
431
431
|
export function coefficientPhaseThicknessDerivatives(coefficientJet, thicknessJets) {
|
|
432
432
|
if (!thicknessJets) return null;
|
|
433
|
-
const result = { phaseDeg: [], gd: [], gdd: [], tod: [] };
|
|
433
|
+
const result = { phaseDeg: [], gd: [], gdd: [], tod: [], logMagnitudeSquared: [] };
|
|
434
434
|
for (const thicknessJet of thicknessJets) {
|
|
435
435
|
const logarithmicDerivative = jetDivide(thicknessJet, coefficientJet);
|
|
436
436
|
const derivatives = jetDerivatives(logarithmicDerivative);
|
|
437
|
+
// The imaginary part of d(ln c)/dd is the phase derivative; the real
|
|
438
|
+
// part is d(ln |c|)/dd, so twice it is the relative derivative of |c|².
|
|
437
439
|
result.phaseDeg.push(-derivatives[0][1] * 180 / Math.PI);
|
|
438
440
|
result.gd.push(derivatives[1][1]);
|
|
439
441
|
result.gdd.push(derivatives[2][1]);
|
|
440
442
|
result.tod.push(derivatives[3][1]);
|
|
443
|
+
result.logMagnitudeSquared.push(2 * derivatives[0][0]);
|
|
441
444
|
}
|
|
442
445
|
return result;
|
|
443
446
|
}
|
|
@@ -500,8 +503,10 @@ export function tmmPhaseDispersion(lambda_nm, theta_deg, pol, n0Jet, nsJet, laye
|
|
|
500
503
|
* thicknesses are skipped and receive zero derivative entries.
|
|
501
504
|
*
|
|
502
505
|
* @returns {{r, t}} where each side is the phase quantities plus
|
|
503
|
-
* `{dPhaseDeg, dGd, dGdd, dTod}`, arrays of length
|
|
504
|
-
*
|
|
506
|
+
* `{dPhaseDeg, dGd, dGdd, dTod, dLogMagnitudeSquared}`, arrays of length
|
|
507
|
+
* `layers.length`. `dLogMagnitudeSquared` is d(ln |coefficient|²)/dd, the
|
|
508
|
+
* relative intensity derivative. The derivative arrays are `null` if the
|
|
509
|
+
* matrix product overflowed.
|
|
505
510
|
*/
|
|
506
511
|
export function tmmPhaseThicknessJacobian(lambda_nm, theta_deg, pol, n0Jet, nsJet, layers, options = {}) {
|
|
507
512
|
const prepared = prepare(lambda_nm, layers, options);
|
|
@@ -524,6 +529,7 @@ export function tmmPhaseThicknessJacobian(lambda_nm, theta_deg, pol, n0Jet, nsJe
|
|
|
524
529
|
dGd: derivatives ? derivatives.gd : null,
|
|
525
530
|
dGdd: derivatives ? derivatives.gdd : null,
|
|
526
531
|
dTod: derivatives ? derivatives.tod : null,
|
|
532
|
+
dLogMagnitudeSquared: derivatives ? derivatives.logMagnitudeSquared : null,
|
|
527
533
|
};
|
|
528
534
|
};
|
|
529
535
|
return {
|