@galihru/mnp 0.1.2 → 0.1.4

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.
Files changed (2) hide show
  1. package/README.md +127 -158
  2. package/package.json +3 -3
package/README.md CHANGED
@@ -1,158 +1,127 @@
1
- # @galihru/mnp
2
-
3
- Integrated computational package for the electromagnetic response of metallic nanoparticles in the Rayleigh quasi-static limit.
4
- Composes dielectric-function evaluation (`@galihru/mnp-material`) with polarizability and cross-section computation (`@galihru/mnp-mie`) to deliver a complete, self-contained simulation API.
5
-
6
- ---
7
-
8
- ## Physical Scope
9
-
10
- This package addresses the **single-nanoparticle optical response problem**: given a metallic sphere of radius *a* ≪ λ embedded in a dielectric host, compute the complex permittivity ε(λ), polarizability α, and electromagnetic cross sections (Cₑₓₜ, Cₛ꜀ₐ, Cₐ꜀ₛ) as a function of illumination wavelength.
11
-
12
- The approach combines:
13
- 1. **Drude free-electron dielectric model** *ε(ω) = ε∞ ωₚ²/[ω(ω + iγ)]*
14
- 2. **Clausius–Mossotti quasi-static polarizability** *α = 4πa³(εₚ − εₘ)/(εₚ + 2εₘ)*
15
- 3. **Optical theorem cross sections** — Cₑₓₜ, Cₛ꜀ₐ, Cₐ꜀ₛ from the induced dipole
16
-
17
- ---
18
-
19
- ## Packages Composed
20
-
21
- | Package | Description |
22
- |---|---|
23
- | [`@galihru/mnp-material`](https://www.npmjs.com/package/@galihru/mnp-material) | Drude dielectric model — Au, Ag, Al; constant ε; wave number |
24
- | [`@galihru/mnp-mie`](https://www.npmjs.com/package/@galihru/mnp-mie) | Rayleigh polarizability and extinction / scattering / absorption cross sections |
25
-
26
- ---
27
-
28
- ## Install
29
-
30
- ```bash
31
- npm install @galihru/mnp
32
- ```
33
-
34
- ---
35
-
36
- ## API Reference
37
-
38
- ### High-level: `simulateSphereResponse(options)`
39
-
40
- Computes the full nanoparticle optical response in one call.
41
-
42
- ```js
43
- import { simulateSphereResponse } from "@galihru/mnp";
44
-
45
- const result = simulateSphereResponse({
46
- material: "Au", // "Au" | "Ag" | "Al"
47
- wavelengthNm: 548.1, // nm, also accepts Array for spectral scan
48
- radiusNm: 50, // nm
49
- mediumRefractiveIndex: 1.33 // dimensionless (water)
50
- });
51
-
52
- console.log(result.epsParticle); // { re: -7.45, im: 1.23 }
53
- console.log(result.alpha); // { re: ..., im: ... } [nm³]
54
- console.log(result.crossSection); // { cExt, cSca, cAbs } [nm²]
55
- ```
56
-
57
- **Return value:**
58
-
59
- | Field | Type | Description |
60
- |---|---|---|
61
- | `inputs` | object | Echo of input parameters |
62
- | `epsParticle` | `{re, im}` | Dielectric function of the metal |
63
- | `epsMedium` | `{re, im}` | Permittivity of embedding medium |
64
- | `alpha` | `{re, im}` | Complex polarizability (nm³) |
65
- | `crossSection` | `{cExt, cSca, cAbs}` | Optical cross sections (nm²) |
66
-
67
- ---
68
-
69
- ### Low-level re-exports
70
-
71
- All functions from sub-packages are directly accessible:
72
-
73
- ```js
74
- import {
75
- // from @galihru/mnp-material
76
- drudeEpsilon, makeDrudeMaterial, constantEpsilon, wavenumberInMedium,
77
- complex, add, sub, mul, div, sqrtComplex, fromReal,
78
- EV_TO_NM, HARTREE_EV,
79
-
80
- // from @galihru/mnp-mie
81
- rayleighPolarizability, rayleighCrossSections
82
- } from "@galihru/mnp";
83
- ```
84
-
85
- ---
86
-
87
- ## Example — Spectral Scan
88
-
89
- ```js
90
- import { drudeEpsilon, constantEpsilon, rayleighCrossSections } from "@galihru/mnp";
91
-
92
- const wavelengths = [400, 450, 500, 548, 600, 700];
93
- const epsAu = drudeEpsilon("Au", wavelengths);
94
- const epsH2O = wavelengths.map(w => constantEpsilon(1.769, w));
95
-
96
- const spectra = rayleighCrossSections(wavelengths, 50, epsAu, epsH2O);
97
- spectra.forEach((cs, i) =>
98
- console.log(`${wavelengths[i]} nm — Cext: ${cs.cExt.toFixed(2)} nm²`)
99
- );
100
- ```
101
-
102
- ---
103
-
104
- ## Author
105
-
106
- **GALIH RIDHO UTOMO** · g4lihru@students.unnes.ac.id
107
- University of Semarang State (UNNES)
108
- License: GPL-2.0-only
109
-
110
-
111
- ## Packages Included
112
-
113
- | Package | Description |
114
- |---|---|
115
- | [`@galihru/mnp-material`](https://www.npmjs.com/package/@galihru/mnp-material) | Dielectric models (Drude, constant, tabulated) |
116
- | [`@galihru/mnp-mie`](https://www.npmjs.com/package/@galihru/mnp-mie) | Rayleigh scattering cross sections |
117
-
118
- ## Install
119
-
120
- ```bash
121
- npm install @galihru/mnp
122
- ```
123
-
124
- ## Usage
125
-
126
- ### High-level API
127
-
128
- ```js
129
- import { simulateSphereResponse } from "@galihru/mnp";
130
-
131
- const result = simulateSphereResponse({
132
- material: "Au",
133
- wavelengthNm: 548.1,
134
- radiusNm: 50,
135
- mediumRefractiveIndex: 1.33
136
- });
137
-
138
- console.log(result.crossSection); // { ext, sca, abs }
139
- console.log(result.epsParticle); // { re, im }
140
- ```
141
-
142
- ### Low-level API
143
-
144
- All exports from sub-packages are re-exported:
145
-
146
- ```js
147
- import {
148
- drudeEpsilon, constantEpsilon, wavenumberInMedium,
149
- rayleighCrossSections, rayleighPolarizability,
150
- complex
151
- } from "@galihru/mnp";
152
- ```
153
-
154
- ## Author
155
-
156
- **GALIH RIDHO UTOMO** — g4lihru@students.unnes.ac.id
157
- License: GPL-2.0-only
158
-
1
+ # @galihru/mnp
2
+
3
+ Integrated computational package for the single-nanoparticle electromagnetic
4
+ response in the Rayleigh quasi-static limit. Composes dielectric-function
5
+ evaluation with polarizability and optical cross-section computation into a
6
+ unified, self-consistent simulation API.
7
+
8
+ ---
9
+
10
+ ## Physical Scope
11
+
12
+ This package solves the **single-nanoparticle optical response problem**: given
13
+ a metallic sphere of radius a << lambda embedded in a dielectric host medium,
14
+ compute as functions of illumination wavelength:
15
+
16
+ 1. Complex permittivity via the **Drude free-electron model**:
17
+
18
+ ![epsilon Drude](https://latex.codecogs.com/svg.latex?\varepsilon(\omega)=\varepsilon_\infty-\frac{\omega_p^2}{\omega(\omega+i\gamma)})
19
+
20
+ 2. Complex polarizability via the **Clausius-Mossotti relation**:
21
+
22
+ ![alpha CM](https://latex.codecogs.com/svg.latex?\alpha=4\pi%20a^3\frac{\varepsilon_p-\varepsilon_m}{\varepsilon_p+2\varepsilon_m})
23
+
24
+ 3. Electromagnetic **cross sections** from the optical theorem:
25
+
26
+ ![cross sections](https://latex.codecogs.com/svg.latex?C_{\mathrm{ext}}=k\,\mathrm{Im}(\alpha),\quad%20C_{\mathrm{sca}}=\frac{|k|^4}{6\pi}|\alpha|^2,\quad%20C_{\mathrm{abs}}=C_{\mathrm{ext}}-C_{\mathrm{sca}})
27
+
28
+ ---
29
+
30
+ ## Composed Packages
31
+
32
+ | Package | Description |
33
+ |---|---|
34
+ | [`@galihru/mnp-material`](https://www.npmjs.com/package/@galihru/mnp-material) | Drude dielectric model for Au, Ag, Al; constant epsilon; complex wave number |
35
+ | [`@galihru/mnp-mie`](https://www.npmjs.com/package/@galihru/mnp-mie) | Rayleigh polarizability; extinction, scattering, and absorption cross sections |
36
+
37
+ ---
38
+
39
+ ## Install
40
+
41
+ ```bash
42
+ npm install @galihru/mnp
43
+ ```
44
+
45
+ ---
46
+
47
+ ## API Reference
48
+
49
+ ### `simulateSphereResponse(options)` -- High-level
50
+
51
+ Computes the complete optical response of a metallic nanosphere in a single call.
52
+
53
+ ```js
54
+ import { simulateSphereResponse } from "@galihru/mnp";
55
+
56
+ const result = simulateSphereResponse({
57
+ material: "Au", // "Au" | "Ag" | "Al"
58
+ wavelengthNm: 548.1, // nm -- scalar or Array for spectral scan
59
+ radiusNm: 50, // nm
60
+ mediumRefractiveIndex: 1.33 // dimensionless refractive index of host medium
61
+ });
62
+ ```
63
+
64
+ **Return value:**
65
+
66
+ | Field | Unit | Description |
67
+ |---|---|---|
68
+ | `inputs` | -- | Echo of all input parameters |
69
+ | `epsParticle` | `{re, im}` | Complex permittivity of the metal particle |
70
+ | `epsMedium` | `{re, im}` | Permittivity of the embedding medium |
71
+ | `alpha` | `{re, im}` nm^3 | Quasi-static complex polarizability |
72
+ | `crossSection.cExt` | nm^2 | Extinction cross section |
73
+ | `crossSection.cSca` | nm^2 | Scattering cross section |
74
+ | `crossSection.cAbs` | nm^2 | Absorption cross section |
75
+
76
+ ---
77
+
78
+ ### Low-level Re-exports
79
+
80
+ All functions from sub-packages are re-exported directly:
81
+
82
+ ```js
83
+ import {
84
+ // Dielectric models
85
+ drudeEpsilon, makeDrudeMaterial, constantEpsilon, wavenumberInMedium,
86
+ // Scattering
87
+ rayleighPolarizability, rayleighCrossSections,
88
+ // Complex arithmetic
89
+ complex, add, sub, mul, div, sqrtComplex, fromReal,
90
+ // Constants
91
+ EV_TO_NM, HARTREE_EV
92
+ } from "@galihru/mnp";
93
+ ```
94
+
95
+ ---
96
+
97
+ ## Example -- Spectral Scan
98
+
99
+ ```js
100
+ import { drudeEpsilon, constantEpsilon, rayleighCrossSections } from "@galihru/mnp";
101
+
102
+ const wavelengths = [400, 450, 500, 548, 600, 700];
103
+
104
+ // Au permittivity across wavelengths
105
+ const epsAu = drudeEpsilon("Au", wavelengths);
106
+
107
+ // Host medium: water (n = 1.33, eps = n^2)
108
+ const epsH2O = wavelengths.map(w => constantEpsilon(1.769, w));
109
+
110
+ // Cross sections for a 50 nm radius Au sphere
111
+ const spectra = rayleighCrossSections(wavelengths, 50, epsAu, epsH2O);
112
+
113
+ spectra.forEach((cs, i) =>
114
+ console.log(
115
+ wavelengths[i] + " nm Cext=" + cs.cExt.toFixed(1) + " nm^2" +
116
+ " Cabs=" + cs.cAbs.toFixed(1) + " nm^2"
117
+ )
118
+ );
119
+ ```
120
+
121
+ ---
122
+
123
+ ## Author
124
+
125
+ **GALIH RIDHO UTOMO** | g4lihru@students.unnes.ac.id
126
+ Universitas Negeri Semarang (UNNES)
127
+ License: GPL-2.0-only
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@galihru/mnp",
3
- "version": "0.1.2",
3
+ "version": "0.1.4",
4
4
  "description": "Integrated electromagnetic response of metallic nanoparticles: Drude dielectric model combined with Rayleigh quasi-static scattering.",
5
5
  "type": "module",
6
6
  "main": "./src/index.js",
@@ -27,8 +27,8 @@
27
27
  "author": "GALIH RIDHO UTOMO <g4lihru@students.unnes.ac.id>",
28
28
  "license": "GPL-2.0-only",
29
29
  "dependencies": {
30
- "@galihru/mnp-material": "0.1.2",
31
- "@galihru/mnp-mie": "0.1.2"
30
+ "@galihru/mnp-material": "0.1.4",
31
+ "@galihru/mnp-mie": "0.1.4"
32
32
  },
33
33
  "repository": {
34
34
  "type": "git",