ramansep 0.2.1__tar.gz

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.
ramansep-0.2.1/LICENSE ADDED
@@ -0,0 +1,202 @@
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+ APPENDIX: How to apply the Apache License to your work.
180
+
181
+ To apply the Apache License to your work, attach the following
182
+ boilerplate notice, with the fields enclosed by brackets "[]"
183
+ replaced with your own identifying information. (Don't include
184
+ the brackets!) The text should be enclosed in the appropriate
185
+ comment syntax for the file format. We also recommend that a
186
+ file or class name and description of purpose be included on the
187
+ same "printed page" as the copyright notice for easier
188
+ identification within third-party archives.
189
+
190
+ Copyright [yyyy] [name of copyright owner]
191
+
192
+ Licensed under the Apache License, Version 2.0 (the "License");
193
+ you may not use this file except in compliance with the License.
194
+ You may obtain a copy of the License at
195
+
196
+ http://www.apache.org/licenses/LICENSE-2.0
197
+
198
+ Unless required by applicable law or agreed to in writing, software
199
+ distributed under the License is distributed on an "AS IS" BASIS,
200
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201
+ See the License for the specific language governing permissions and
202
+ limitations under the License.
@@ -0,0 +1,134 @@
1
+ Metadata-Version: 2.4
2
+ Name: ramansep
3
+ Version: 0.2.1
4
+ Summary: Separate strain from carrier density in 2D-material Raman maps using a two-mode linear inversion
5
+ Author-email: "Tanvir M. Mahim" <tanvir.mahim@bracu.ac.bd>
6
+ License: Apache-2.0
7
+ Project-URL: Homepage, https://tanvir-mahmud-mahim.github.io/software/
8
+ Project-URL: Repository, https://github.com/TaN-MM-Org/ramansep
9
+ Project-URL: Issues, https://github.com/TaN-MM-Org/ramansep/issues
10
+ Project-URL: Changelog, https://github.com/TaN-MM-Org/ramansep/releases
11
+ Keywords: Raman spectroscopy,2D materials,MoS2,strain,carrier density,TMD
12
+ Classifier: Development Status :: 3 - Alpha
13
+ Classifier: Intended Audience :: Science/Research
14
+ Classifier: License :: OSI Approved :: Apache Software License
15
+ Classifier: Programming Language :: Python :: 3
16
+ Classifier: Topic :: Scientific/Engineering :: Physics
17
+ Requires-Python: >=3.9
18
+ Description-Content-Type: text/markdown
19
+ License-File: LICENSE
20
+ Requires-Dist: numpy>=1.22
21
+ Provides-Extra: plot
22
+ Requires-Dist: matplotlib; extra == "plot"
23
+ Provides-Extra: test
24
+ Requires-Dist: pytest; extra == "test"
25
+ Dynamic: license-file
26
+
27
+ # ramansep
28
+
29
+ [![DOI](https://img.shields.io/badge/DOI-10.5281%2Fzenodo.22014913-blue)](https://doi.org/10.5281/zenodo.22014913) [![tests](https://github.com/TaN-MM-Org/ramansep/actions/workflows/ci.yml/badge.svg)](https://github.com/TaN-MM-Org/ramansep/actions)
30
+
31
+ Separate **strain** from **carrier density** in Raman maps of 2D materials,
32
+ using two phonon modes whose lever arms differ.
33
+
34
+ A single Raman frequency responds to strain and to carrier density at once,
35
+ so one mode cannot tell the two apart. Two modes with sufficiently different
36
+ responses form a linear, invertible probe: measure both shift maps, invert a
37
+ 2x2 matrix per pixel, and obtain a strain map and a carrier-density map with
38
+ propagated uncertainties.
39
+
40
+ ## Status
41
+
42
+ v0.2.0 (alpha). The inversion core, uncertainty propagation, conditioning
43
+ diagnostics, a synthetic end-to-end example, and two cited coefficient
44
+ sets for monolayer MoS2 are implemented and tested. The API may change
45
+ before v1.0.
46
+
47
+ ## Cited coefficient sets (new in v0.2)
48
+
49
+ Two example sets for monolayer 1H-MoS2 ship with full provenance, and the
50
+ test-suite reproduces the published separation results of the source paper
51
+ from them (edge charge of 2.3e12 cm^-2 from a 0.5 cm^-1 A'1 redshift with
52
+ 2LA(M) unmoved; 0.134% interior tension carrying no significant charge):
53
+
54
+ - `mos2_a1_2la()`: the A'1 + 2LA(M) pair of the source paper. Strain lever
55
+ arms -5.1 and -20.9 cm^-1 per percent of biaxial strain (frozen-phonon
56
+ DFT, ratio 4.1); A'1 doping coefficient -2.2 cm^-1 per 1e13 cm^-2 of
57
+ electrons (measured, Chakraborty et al., Phys. Rev. B 85, 161403(R)
58
+ (2012)). The 2LA(M) doping coefficient is unmeasured and set to zero;
59
+ the source paper bounds the consequence of that choice at 16% of a
60
+ recovered edge charge.
61
+ - `mos2_eprime_a1()`: the historically used all-optical E' + A'1 pair,
62
+ built from the measured biaxial Grueneisen parameters of Michail et al.,
63
+ ACS Appl. Mater. Interfaces 16, 49602 (2024). Both optical modes respond
64
+ weakly to strain, so for equal shift noise this pair returns about five
65
+ times the strain uncertainty of the A'1 + 2LA(M) pair; it is included
66
+ for comparison and for workflows where the overtone is not available.
67
+
68
+ Each function's docstring states which number comes from which source and
69
+ the conditions of applicability (1H monolayer, SiO2-supported, 300 K;
70
+ 532 nm for the disorder-activated calibration). Check that your sample
71
+ matches before use.
72
+
73
+ ## What this package deliberately does not include
74
+
75
+ No constants beyond the two documented MoS2 sets are shipped. Lever arms
76
+ depend on material, mode pair, excitation wavelength and substrate; a
77
+ measurement tool that ships unverified constants propagates wrong results.
78
+ For any other system you provide a `ModeCoefficients` from the literature
79
+ or your own calibration, and the `reference` field is mandatory so the
80
+ provenance of every number travels with the analysis.
81
+
82
+ ## Install
83
+
84
+ ```
85
+ pip install -e .
86
+ ```
87
+
88
+ ## Use
89
+
90
+ ```python
91
+ import numpy as np
92
+ from ramansep import SeparationModel, ModeCoefficients
93
+
94
+ coeffs = ModeCoefficients(
95
+ mode1_name="A'1", mode2_name="2LA(M)",
96
+ k1_strain=..., # cm^-1 per unit strain, from your calibration
97
+ k1_density=..., # cm^-1 per unit carrier density
98
+ k2_strain=...,
99
+ k2_density=...,
100
+ reference="cite the source of these numbers",
101
+ )
102
+ model = SeparationModel(coeffs)
103
+ result = model.invert(dw_mode1, dw_mode2, sigma1=0.1, sigma2=0.1)
104
+ # result.strain, result.density, result.strain_sigma, result.density_sigma
105
+ ```
106
+
107
+ `SeparationModel` warns when the mode pair is poorly conditioned, i.e. when
108
+ the two modes respond too similarly for a reliable separation.
109
+
110
+ ## Method
111
+
112
+ The method of using the first-order A'1 mode together with the
113
+ disorder-activated 2LA(M) overtone, whose strain lever arms differ
114
+ severalfold while only A'1 responds appreciably to carrier density, is
115
+ developed in:
116
+
117
+ > T. M. Mahim and M. M. Rahman, "Two Raman phonons quantify the fixed edge
118
+ > charge left by patterning monolayer transition metal dichalcogenides"
119
+ > (under review). Code for the paper itself:
120
+ > https://github.com/Tanvir-Mahmud-Mahim/Width-scaling-in-monolayer-semiconductor-nanoribbon-transistors
121
+
122
+ This package is the general-purpose, material-agnostic inversion tool; the
123
+ paper repository reproduces the specific published study.
124
+
125
+ ## Roadmap
126
+
127
+ - v0.2 (done): documented example coefficient sets with citations
128
+ - v0.3: peak-fitting front end (load spectra, fit the two modes, feed the
129
+ inversion)
130
+ - v0.4: joint Bayesian inversion with spatial priors
131
+
132
+ ## License
133
+
134
+ Apache-2.0
@@ -0,0 +1,108 @@
1
+ # ramansep
2
+
3
+ [![DOI](https://img.shields.io/badge/DOI-10.5281%2Fzenodo.22014913-blue)](https://doi.org/10.5281/zenodo.22014913) [![tests](https://github.com/TaN-MM-Org/ramansep/actions/workflows/ci.yml/badge.svg)](https://github.com/TaN-MM-Org/ramansep/actions)
4
+
5
+ Separate **strain** from **carrier density** in Raman maps of 2D materials,
6
+ using two phonon modes whose lever arms differ.
7
+
8
+ A single Raman frequency responds to strain and to carrier density at once,
9
+ so one mode cannot tell the two apart. Two modes with sufficiently different
10
+ responses form a linear, invertible probe: measure both shift maps, invert a
11
+ 2x2 matrix per pixel, and obtain a strain map and a carrier-density map with
12
+ propagated uncertainties.
13
+
14
+ ## Status
15
+
16
+ v0.2.0 (alpha). The inversion core, uncertainty propagation, conditioning
17
+ diagnostics, a synthetic end-to-end example, and two cited coefficient
18
+ sets for monolayer MoS2 are implemented and tested. The API may change
19
+ before v1.0.
20
+
21
+ ## Cited coefficient sets (new in v0.2)
22
+
23
+ Two example sets for monolayer 1H-MoS2 ship with full provenance, and the
24
+ test-suite reproduces the published separation results of the source paper
25
+ from them (edge charge of 2.3e12 cm^-2 from a 0.5 cm^-1 A'1 redshift with
26
+ 2LA(M) unmoved; 0.134% interior tension carrying no significant charge):
27
+
28
+ - `mos2_a1_2la()`: the A'1 + 2LA(M) pair of the source paper. Strain lever
29
+ arms -5.1 and -20.9 cm^-1 per percent of biaxial strain (frozen-phonon
30
+ DFT, ratio 4.1); A'1 doping coefficient -2.2 cm^-1 per 1e13 cm^-2 of
31
+ electrons (measured, Chakraborty et al., Phys. Rev. B 85, 161403(R)
32
+ (2012)). The 2LA(M) doping coefficient is unmeasured and set to zero;
33
+ the source paper bounds the consequence of that choice at 16% of a
34
+ recovered edge charge.
35
+ - `mos2_eprime_a1()`: the historically used all-optical E' + A'1 pair,
36
+ built from the measured biaxial Grueneisen parameters of Michail et al.,
37
+ ACS Appl. Mater. Interfaces 16, 49602 (2024). Both optical modes respond
38
+ weakly to strain, so for equal shift noise this pair returns about five
39
+ times the strain uncertainty of the A'1 + 2LA(M) pair; it is included
40
+ for comparison and for workflows where the overtone is not available.
41
+
42
+ Each function's docstring states which number comes from which source and
43
+ the conditions of applicability (1H monolayer, SiO2-supported, 300 K;
44
+ 532 nm for the disorder-activated calibration). Check that your sample
45
+ matches before use.
46
+
47
+ ## What this package deliberately does not include
48
+
49
+ No constants beyond the two documented MoS2 sets are shipped. Lever arms
50
+ depend on material, mode pair, excitation wavelength and substrate; a
51
+ measurement tool that ships unverified constants propagates wrong results.
52
+ For any other system you provide a `ModeCoefficients` from the literature
53
+ or your own calibration, and the `reference` field is mandatory so the
54
+ provenance of every number travels with the analysis.
55
+
56
+ ## Install
57
+
58
+ ```
59
+ pip install -e .
60
+ ```
61
+
62
+ ## Use
63
+
64
+ ```python
65
+ import numpy as np
66
+ from ramansep import SeparationModel, ModeCoefficients
67
+
68
+ coeffs = ModeCoefficients(
69
+ mode1_name="A'1", mode2_name="2LA(M)",
70
+ k1_strain=..., # cm^-1 per unit strain, from your calibration
71
+ k1_density=..., # cm^-1 per unit carrier density
72
+ k2_strain=...,
73
+ k2_density=...,
74
+ reference="cite the source of these numbers",
75
+ )
76
+ model = SeparationModel(coeffs)
77
+ result = model.invert(dw_mode1, dw_mode2, sigma1=0.1, sigma2=0.1)
78
+ # result.strain, result.density, result.strain_sigma, result.density_sigma
79
+ ```
80
+
81
+ `SeparationModel` warns when the mode pair is poorly conditioned, i.e. when
82
+ the two modes respond too similarly for a reliable separation.
83
+
84
+ ## Method
85
+
86
+ The method of using the first-order A'1 mode together with the
87
+ disorder-activated 2LA(M) overtone, whose strain lever arms differ
88
+ severalfold while only A'1 responds appreciably to carrier density, is
89
+ developed in:
90
+
91
+ > T. M. Mahim and M. M. Rahman, "Two Raman phonons quantify the fixed edge
92
+ > charge left by patterning monolayer transition metal dichalcogenides"
93
+ > (under review). Code for the paper itself:
94
+ > https://github.com/Tanvir-Mahmud-Mahim/Width-scaling-in-monolayer-semiconductor-nanoribbon-transistors
95
+
96
+ This package is the general-purpose, material-agnostic inversion tool; the
97
+ paper repository reproduces the specific published study.
98
+
99
+ ## Roadmap
100
+
101
+ - v0.2 (done): documented example coefficient sets with citations
102
+ - v0.3: peak-fitting front end (load spectra, fit the two modes, feed the
103
+ inversion)
104
+ - v0.4: joint Bayesian inversion with spatial priors
105
+
106
+ ## License
107
+
108
+ Apache-2.0
@@ -0,0 +1,34 @@
1
+ [build-system]
2
+ requires = ["setuptools>=68"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "ramansep"
7
+ version = "0.2.1"
8
+ description = "Separate strain from carrier density in 2D-material Raman maps using a two-mode linear inversion"
9
+ readme = "README.md"
10
+ license = { text = "Apache-2.0" }
11
+ authors = [{ name = "Tanvir M. Mahim", email = "tanvir.mahim@bracu.ac.bd" }]
12
+ requires-python = ">=3.9"
13
+ keywords = ["Raman spectroscopy", "2D materials", "MoS2", "strain", "carrier density", "TMD"]
14
+ dependencies = ["numpy>=1.22"]
15
+ classifiers = [
16
+ "Development Status :: 3 - Alpha",
17
+ "Intended Audience :: Science/Research",
18
+ "License :: OSI Approved :: Apache Software License",
19
+ "Programming Language :: Python :: 3",
20
+ "Topic :: Scientific/Engineering :: Physics",
21
+ ]
22
+
23
+ [project.optional-dependencies]
24
+ plot = ["matplotlib"]
25
+ test = ["pytest"]
26
+
27
+ [project.urls]
28
+ Homepage = "https://tanvir-mahmud-mahim.github.io/software/"
29
+ Repository = "https://github.com/TaN-MM-Org/ramansep"
30
+ Issues = "https://github.com/TaN-MM-Org/ramansep/issues"
31
+ Changelog = "https://github.com/TaN-MM-Org/ramansep/releases"
32
+
33
+ [tool.setuptools.packages.find]
34
+ where = ["src"]
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,19 @@
1
+ """ramansep: separate strain from carrier density in 2D-material Raman maps.
2
+
3
+ Two Raman modes with different strain lever arms and different doping
4
+ responses form a linear, invertible probe of the (strain, carrier density)
5
+ state at each map pixel. This package implements that inversion with full
6
+ uncertainty propagation and conditioning diagnostics.
7
+
8
+ Methodological basis: T. M. Mahim and M. M. Rahman, "Two Raman phonons
9
+ quantify the fixed edge charge left by patterning monolayer transition
10
+ metal dichalcogenides" (under review). The solver is material-agnostic:
11
+ you supply the coefficient matrix for your material and mode pair.
12
+ """
13
+ from .core import SeparationModel, SeparationResult
14
+ from .materials import (ModeCoefficients, mos2_a1_2la, mos2_eprime_a1,
15
+ synthetic_demo)
16
+
17
+ __version__ = "0.2.1"
18
+ __all__ = ["SeparationModel", "SeparationResult", "ModeCoefficients",
19
+ "synthetic_demo", "mos2_a1_2la", "mos2_eprime_a1"]
@@ -0,0 +1,126 @@
1
+ """Linear two-mode separation of strain and carrier density."""
2
+ from __future__ import annotations
3
+
4
+ import dataclasses
5
+ import warnings
6
+
7
+ import numpy as np
8
+
9
+ from .materials import ModeCoefficients
10
+
11
+
12
+ @dataclasses.dataclass
13
+ class SeparationResult:
14
+ """Result of a two-mode inversion.
15
+
16
+ Attributes
17
+ ----------
18
+ strain : ndarray
19
+ Strain field, in the strain unit of the coefficient matrix
20
+ (percent biaxial strain unless your coefficients say otherwise).
21
+ density : ndarray
22
+ Carrier-density field, in the density unit of the coefficient
23
+ matrix (cm^-2 unless your coefficients say otherwise).
24
+ strain_sigma, density_sigma : ndarray or None
25
+ One-standard-deviation uncertainties propagated from the peak-shift
26
+ uncertainties, if those were provided.
27
+ correlation : ndarray or None
28
+ Pixelwise correlation coefficient between the strain and density
29
+ estimates. Values near +/-1 mean the two modes barely separate the
30
+ two causes at that pixel.
31
+ condition_number : float
32
+ Condition number of the coefficient matrix. Large values mean the
33
+ mode pair is poorly chosen for separation.
34
+ """
35
+
36
+ strain: np.ndarray
37
+ density: np.ndarray
38
+ strain_sigma: np.ndarray | None
39
+ density_sigma: np.ndarray | None
40
+ correlation: np.ndarray | None
41
+ condition_number: float
42
+
43
+
44
+ class SeparationModel:
45
+ """Invert two peak-shift maps into strain and carrier-density maps.
46
+
47
+ Parameters
48
+ ----------
49
+ coefficients : ModeCoefficients
50
+ The 2x2 lever-arm matrix K such that
51
+
52
+ [dw_mode1] [k1_strain k1_density] [strain ]
53
+ [dw_mode2] = [k2_strain k2_density] [density]
54
+
55
+ where dw are peak shifts relative to the pristine reference.
56
+ condition_warn : float
57
+ Warn if the condition number of K exceeds this value.
58
+ """
59
+
60
+ def __init__(self, coefficients: ModeCoefficients, condition_warn: float = 30.0):
61
+ self.coefficients = coefficients
62
+ self.K = np.asarray(coefficients.matrix(), dtype=float)
63
+ if self.K.shape != (2, 2):
64
+ raise ValueError("coefficient matrix must be 2x2")
65
+ det = np.linalg.det(self.K)
66
+ if det == 0.0:
67
+ raise ValueError(
68
+ "coefficient matrix is singular: the two modes respond "
69
+ "identically and cannot separate strain from density"
70
+ )
71
+ self.condition_number = float(np.linalg.cond(self.K))
72
+ if self.condition_number > condition_warn:
73
+ warnings.warn(
74
+ f"coefficient matrix condition number is "
75
+ f"{self.condition_number:.1f}; the mode pair is poorly "
76
+ "conditioned and small shift errors will produce large "
77
+ "strain/density errors",
78
+ stacklevel=2,
79
+ )
80
+ self.Kinv = np.linalg.inv(self.K)
81
+
82
+ def invert(self, dw1, dw2, sigma1=None, sigma2=None) -> SeparationResult:
83
+ """Invert peak-shift maps (any matching numpy shapes) pixelwise.
84
+
85
+ dw1, dw2 : peak shifts of mode 1 and mode 2 (cm^-1), relative to the
86
+ pristine-material reference frequency of each mode.
87
+ sigma1, sigma2 : optional 1-sigma uncertainties of the shifts,
88
+ scalar or arrays broadcastable to the map shape.
89
+ """
90
+ dw1 = np.asarray(dw1, dtype=float)
91
+ dw2 = np.asarray(dw2, dtype=float)
92
+ if dw1.shape != dw2.shape:
93
+ raise ValueError("the two shift maps must have the same shape")
94
+
95
+ strain = self.Kinv[0, 0] * dw1 + self.Kinv[0, 1] * dw2
96
+ density = self.Kinv[1, 0] * dw1 + self.Kinv[1, 1] * dw2
97
+
98
+ strain_sigma = density_sigma = correlation = None
99
+ if sigma1 is not None and sigma2 is not None:
100
+ s1 = np.broadcast_to(np.asarray(sigma1, dtype=float), dw1.shape)
101
+ s2 = np.broadcast_to(np.asarray(sigma2, dtype=float), dw2.shape)
102
+ var_strain = (self.Kinv[0, 0] * s1) ** 2 + (self.Kinv[0, 1] * s2) ** 2
103
+ var_density = (self.Kinv[1, 0] * s1) ** 2 + (self.Kinv[1, 1] * s2) ** 2
104
+ cov = (self.Kinv[0, 0] * self.Kinv[1, 0] * s1**2
105
+ + self.Kinv[0, 1] * self.Kinv[1, 1] * s2**2)
106
+ strain_sigma = np.sqrt(var_strain)
107
+ density_sigma = np.sqrt(var_density)
108
+ with np.errstate(invalid="ignore", divide="ignore"):
109
+ correlation = cov / (strain_sigma * density_sigma)
110
+
111
+ return SeparationResult(
112
+ strain=strain,
113
+ density=density,
114
+ strain_sigma=strain_sigma,
115
+ density_sigma=density_sigma,
116
+ correlation=correlation,
117
+ condition_number=self.condition_number,
118
+ )
119
+
120
+ def forward(self, strain, density):
121
+ """Predict the two peak shifts from strain and density maps."""
122
+ strain = np.asarray(strain, dtype=float)
123
+ density = np.asarray(density, dtype=float)
124
+ dw1 = self.K[0, 0] * strain + self.K[0, 1] * density
125
+ dw2 = self.K[1, 0] * strain + self.K[1, 1] * density
126
+ return dw1, dw2
@@ -0,0 +1,156 @@
1
+ """Coefficient sets for mode pairs.
2
+
3
+ This module ships two CITED example coefficient sets for monolayer 1H-MoS2
4
+ (see mos2_a1_2la and mos2_eprime_a1 below), plus a synthetic set for the
5
+ test-suite. Every number in the cited sets is traceable to a published
6
+ measurement or to the first-principles calculation of the reference given
7
+ in its `reference` field; the docstring of each function states which
8
+ numbers come from where.
9
+
10
+ The warning of v0.1 still applies in general: peak-shift lever arms depend
11
+ on material, mode pair, excitation wavelength and substrate. Before using
12
+ either MoS2 set on your own spectra, check that your sample, excitation
13
+ and substrate match the conditions stated in the sources. For any other
14
+ material or mode pair, populate a ModeCoefficients from the literature or
15
+ from your own calibration; the mandatory `reference` field keeps the
16
+ provenance attached to the analysis.
17
+
18
+ Units used by both MoS2 sets:
19
+ strain : percent biaxial strain (positive = tension)
20
+ density : electron sheet density in units of 1e13 cm^-2
21
+ shifts : cm^-1 (softening, i.e. redshift, is negative)
22
+ """
23
+ from __future__ import annotations
24
+
25
+ import dataclasses
26
+
27
+
28
+ @dataclasses.dataclass
29
+ class ModeCoefficients:
30
+ """Lever arms of two Raman modes.
31
+
32
+ Units are your choice but must be consistent; the inversion returns
33
+ strain and density in whatever units these coefficients imply.
34
+
35
+ mode1_name, mode2_name : labels, e.g. "A'1" and "2LA(M)".
36
+ k1_strain : shift of mode 1 per unit strain (e.g. cm^-1 / %)
37
+ k1_density : shift of mode 1 per unit carrier density (e.g. cm^-1 / 1e13 cm^-2)
38
+ k2_strain, k2_density : same for mode 2.
39
+ reference : where the numbers come from. Required, on purpose.
40
+ """
41
+
42
+ mode1_name: str
43
+ mode2_name: str
44
+ k1_strain: float
45
+ k1_density: float
46
+ k2_strain: float
47
+ k2_density: float
48
+ reference: str
49
+
50
+ def matrix(self):
51
+ return [[self.k1_strain, self.k1_density],
52
+ [self.k2_strain, self.k2_density]]
53
+
54
+
55
+ def synthetic_demo() -> ModeCoefficients:
56
+ """An arbitrary, NON-PHYSICAL coefficient set for tests and demos.
57
+
58
+ The values are chosen only to be well-conditioned. Do not use for
59
+ analysis of real spectra.
60
+ """
61
+ return ModeCoefficients(
62
+ mode1_name="demo-mode-1",
63
+ mode2_name="demo-mode-2",
64
+ k1_strain=-2.0,
65
+ k1_density=-0.8,
66
+ k2_strain=-6.0,
67
+ k2_density=-0.1,
68
+ reference="synthetic demonstration values; not physical",
69
+ )
70
+
71
+
72
+ def mos2_a1_2la() -> ModeCoefficients:
73
+ """Monolayer 1H-MoS2, A'1 + 2LA(M) pair (the pair of the source paper).
74
+
75
+ Strain lever arms are the frozen-phonon DFT values computed in the
76
+ source paper: the A'1 mode softens by 5.1 cm^-1 per percent of biaxial
77
+ tension and the disorder-activated 2LA(M) overtone by 20.9 cm^-1 per
78
+ percent (acoustic Grueneisen parameter gamma_LA = 2.30), a lever-arm
79
+ ratio of 4.1. The A'1 doping coefficient is the gated-Raman measurement
80
+ of Chakraborty et al.: a softening of 2.2 cm^-1 per 1e13 cm^-2 of
81
+ electrons, from the symmetry-selective coupling of the out-of-plane
82
+ mode to the K-valley density; the E'-symmetry channel, and with it the
83
+ 2LA(M) overtone, couples only weakly.
84
+
85
+ CAVEAT carried over from the source paper: no gated measurement of the
86
+ 2LA(M) doping coefficient exists, so it is set to zero here rather than
87
+ known to be zero. The source paper bounds the consequence: letting the
88
+ overtone renormalize at up to half the frequency-scaled A'1 rate
89
+ changes a recovered edge charge by 16 percent.
90
+
91
+ Units: percent biaxial strain; electron density in 1e13 cm^-2.
92
+ Applicability: 1H monolayer, 532 nm excitation, SiO2-supported, 300 K.
93
+ """
94
+ return ModeCoefficients(
95
+ mode1_name="A'1",
96
+ mode2_name="2LA(M)",
97
+ k1_strain=-5.1,
98
+ k1_density=-2.2,
99
+ k2_strain=-20.9,
100
+ k2_density=0.0,
101
+ reference=(
102
+ "Strain lever arms (DFT, frozen phonon): T. M. Mahim and "
103
+ "M. M. Rahman, 'Two Raman phonons quantify the fixed edge "
104
+ "charge left by patterning monolayer transition metal "
105
+ "dichalcogenides' (under review); code and data: "
106
+ "github.com/Tanvir-Mahmud-Mahim/Width-scaling-in-monolayer-"
107
+ "semiconductor-nanoribbon-transistors, "
108
+ "doi:10.5281/zenodo.21778170. A'1 doping coefficient "
109
+ "(measured): B. Chakraborty et al., Phys. Rev. B 85, "
110
+ "161403(R) (2012). 2LA(M) doping coefficient set to zero "
111
+ "(unmeasured; see docstring caveat)."
112
+ ),
113
+ )
114
+
115
+
116
+ def mos2_eprime_a1() -> ModeCoefficients:
117
+ """Monolayer 1H-MoS2, E' + A'1 pair, from direct biaxial measurements.
118
+
119
+ Strain lever arms follow from the measured biaxial-strain mode
120
+ Grueneisen parameters of Michail et al. (gamma_E' = 0.56,
121
+ gamma_A'1 = 0.31, in the convention gamma = -(1/2w) dw/deps) applied
122
+ to the mode frequencies w(E') = 385.0 cm^-1 and w(A'1) = 403.0 cm^-1:
123
+ dw/deps = -2 gamma w = -4.31 (E') and -2.50 (A'1) cm^-1 per percent
124
+ of biaxial strain. Doping coefficients are the gated-Raman
125
+ measurements of Chakraborty et al.: -0.33 (E') and -2.2 (A'1) cm^-1
126
+ per 1e13 cm^-2 of electrons.
127
+
128
+ This is the historically used all-optical pair (Michail et al. 2016).
129
+ Both optical modes respond weakly to strain (lever arms of -4.31 and
130
+ -2.50 cm^-1 per percent, against -20.9 for the 2LA(M) overtone), so
131
+ for equal peak-shift noise this pair returns a strain uncertainty
132
+ about five times larger than mos2_a1_2la(); propagate sigmas through
133
+ invert() and compare strain_sigma before choosing it.
134
+
135
+ Units: percent biaxial strain; electron density in 1e13 cm^-2.
136
+ Applicability: 1H monolayer, SiO2-supported, 300 K.
137
+ """
138
+ return ModeCoefficients(
139
+ mode1_name="E'",
140
+ mode2_name="A'1",
141
+ k1_strain=-4.31,
142
+ k1_density=-0.33,
143
+ k2_strain=-2.50,
144
+ k2_density=-2.2,
145
+ reference=(
146
+ "Strain: measured biaxial Grueneisen parameters, A. Michail "
147
+ "et al., ACS Appl. Mater. Interfaces 16, 49602 (2024) "
148
+ "(gamma_E'=0.56, gamma_A'1=0.31), converted with "
149
+ "w(E')=385.0 cm^-1 and w(A'1)=403.0 cm^-1 (Mignuzzi et al., "
150
+ "Phys. Rev. B 91, 195411 (2015); Michail et al., Appl. Phys. "
151
+ "Lett. 108, 173102 (2016)). Doping (measured): B. Chakraborty "
152
+ "et al., Phys. Rev. B 85, 161403(R) (2012). Compiled as in "
153
+ "T. M. Mahim and M. M. Rahman (under review), "
154
+ "doi:10.5281/zenodo.21778170."
155
+ ),
156
+ )
@@ -0,0 +1,134 @@
1
+ Metadata-Version: 2.4
2
+ Name: ramansep
3
+ Version: 0.2.1
4
+ Summary: Separate strain from carrier density in 2D-material Raman maps using a two-mode linear inversion
5
+ Author-email: "Tanvir M. Mahim" <tanvir.mahim@bracu.ac.bd>
6
+ License: Apache-2.0
7
+ Project-URL: Homepage, https://tanvir-mahmud-mahim.github.io/software/
8
+ Project-URL: Repository, https://github.com/TaN-MM-Org/ramansep
9
+ Project-URL: Issues, https://github.com/TaN-MM-Org/ramansep/issues
10
+ Project-URL: Changelog, https://github.com/TaN-MM-Org/ramansep/releases
11
+ Keywords: Raman spectroscopy,2D materials,MoS2,strain,carrier density,TMD
12
+ Classifier: Development Status :: 3 - Alpha
13
+ Classifier: Intended Audience :: Science/Research
14
+ Classifier: License :: OSI Approved :: Apache Software License
15
+ Classifier: Programming Language :: Python :: 3
16
+ Classifier: Topic :: Scientific/Engineering :: Physics
17
+ Requires-Python: >=3.9
18
+ Description-Content-Type: text/markdown
19
+ License-File: LICENSE
20
+ Requires-Dist: numpy>=1.22
21
+ Provides-Extra: plot
22
+ Requires-Dist: matplotlib; extra == "plot"
23
+ Provides-Extra: test
24
+ Requires-Dist: pytest; extra == "test"
25
+ Dynamic: license-file
26
+
27
+ # ramansep
28
+
29
+ [![DOI](https://img.shields.io/badge/DOI-10.5281%2Fzenodo.22014913-blue)](https://doi.org/10.5281/zenodo.22014913) [![tests](https://github.com/TaN-MM-Org/ramansep/actions/workflows/ci.yml/badge.svg)](https://github.com/TaN-MM-Org/ramansep/actions)
30
+
31
+ Separate **strain** from **carrier density** in Raman maps of 2D materials,
32
+ using two phonon modes whose lever arms differ.
33
+
34
+ A single Raman frequency responds to strain and to carrier density at once,
35
+ so one mode cannot tell the two apart. Two modes with sufficiently different
36
+ responses form a linear, invertible probe: measure both shift maps, invert a
37
+ 2x2 matrix per pixel, and obtain a strain map and a carrier-density map with
38
+ propagated uncertainties.
39
+
40
+ ## Status
41
+
42
+ v0.2.0 (alpha). The inversion core, uncertainty propagation, conditioning
43
+ diagnostics, a synthetic end-to-end example, and two cited coefficient
44
+ sets for monolayer MoS2 are implemented and tested. The API may change
45
+ before v1.0.
46
+
47
+ ## Cited coefficient sets (new in v0.2)
48
+
49
+ Two example sets for monolayer 1H-MoS2 ship with full provenance, and the
50
+ test-suite reproduces the published separation results of the source paper
51
+ from them (edge charge of 2.3e12 cm^-2 from a 0.5 cm^-1 A'1 redshift with
52
+ 2LA(M) unmoved; 0.134% interior tension carrying no significant charge):
53
+
54
+ - `mos2_a1_2la()`: the A'1 + 2LA(M) pair of the source paper. Strain lever
55
+ arms -5.1 and -20.9 cm^-1 per percent of biaxial strain (frozen-phonon
56
+ DFT, ratio 4.1); A'1 doping coefficient -2.2 cm^-1 per 1e13 cm^-2 of
57
+ electrons (measured, Chakraborty et al., Phys. Rev. B 85, 161403(R)
58
+ (2012)). The 2LA(M) doping coefficient is unmeasured and set to zero;
59
+ the source paper bounds the consequence of that choice at 16% of a
60
+ recovered edge charge.
61
+ - `mos2_eprime_a1()`: the historically used all-optical E' + A'1 pair,
62
+ built from the measured biaxial Grueneisen parameters of Michail et al.,
63
+ ACS Appl. Mater. Interfaces 16, 49602 (2024). Both optical modes respond
64
+ weakly to strain, so for equal shift noise this pair returns about five
65
+ times the strain uncertainty of the A'1 + 2LA(M) pair; it is included
66
+ for comparison and for workflows where the overtone is not available.
67
+
68
+ Each function's docstring states which number comes from which source and
69
+ the conditions of applicability (1H monolayer, SiO2-supported, 300 K;
70
+ 532 nm for the disorder-activated calibration). Check that your sample
71
+ matches before use.
72
+
73
+ ## What this package deliberately does not include
74
+
75
+ No constants beyond the two documented MoS2 sets are shipped. Lever arms
76
+ depend on material, mode pair, excitation wavelength and substrate; a
77
+ measurement tool that ships unverified constants propagates wrong results.
78
+ For any other system you provide a `ModeCoefficients` from the literature
79
+ or your own calibration, and the `reference` field is mandatory so the
80
+ provenance of every number travels with the analysis.
81
+
82
+ ## Install
83
+
84
+ ```
85
+ pip install -e .
86
+ ```
87
+
88
+ ## Use
89
+
90
+ ```python
91
+ import numpy as np
92
+ from ramansep import SeparationModel, ModeCoefficients
93
+
94
+ coeffs = ModeCoefficients(
95
+ mode1_name="A'1", mode2_name="2LA(M)",
96
+ k1_strain=..., # cm^-1 per unit strain, from your calibration
97
+ k1_density=..., # cm^-1 per unit carrier density
98
+ k2_strain=...,
99
+ k2_density=...,
100
+ reference="cite the source of these numbers",
101
+ )
102
+ model = SeparationModel(coeffs)
103
+ result = model.invert(dw_mode1, dw_mode2, sigma1=0.1, sigma2=0.1)
104
+ # result.strain, result.density, result.strain_sigma, result.density_sigma
105
+ ```
106
+
107
+ `SeparationModel` warns when the mode pair is poorly conditioned, i.e. when
108
+ the two modes respond too similarly for a reliable separation.
109
+
110
+ ## Method
111
+
112
+ The method of using the first-order A'1 mode together with the
113
+ disorder-activated 2LA(M) overtone, whose strain lever arms differ
114
+ severalfold while only A'1 responds appreciably to carrier density, is
115
+ developed in:
116
+
117
+ > T. M. Mahim and M. M. Rahman, "Two Raman phonons quantify the fixed edge
118
+ > charge left by patterning monolayer transition metal dichalcogenides"
119
+ > (under review). Code for the paper itself:
120
+ > https://github.com/Tanvir-Mahmud-Mahim/Width-scaling-in-monolayer-semiconductor-nanoribbon-transistors
121
+
122
+ This package is the general-purpose, material-agnostic inversion tool; the
123
+ paper repository reproduces the specific published study.
124
+
125
+ ## Roadmap
126
+
127
+ - v0.2 (done): documented example coefficient sets with citations
128
+ - v0.3: peak-fitting front end (load spectra, fit the two modes, feed the
129
+ inversion)
130
+ - v0.4: joint Bayesian inversion with spatial priors
131
+
132
+ ## License
133
+
134
+ Apache-2.0
@@ -0,0 +1,13 @@
1
+ LICENSE
2
+ README.md
3
+ pyproject.toml
4
+ src/ramansep/__init__.py
5
+ src/ramansep/core.py
6
+ src/ramansep/materials.py
7
+ src/ramansep.egg-info/PKG-INFO
8
+ src/ramansep.egg-info/SOURCES.txt
9
+ src/ramansep.egg-info/dependency_links.txt
10
+ src/ramansep.egg-info/requires.txt
11
+ src/ramansep.egg-info/top_level.txt
12
+ tests/test_core.py
13
+ tests/test_mos2_sets.py
@@ -0,0 +1,7 @@
1
+ numpy>=1.22
2
+
3
+ [plot]
4
+ matplotlib
5
+
6
+ [test]
7
+ pytest
@@ -0,0 +1 @@
1
+ ramansep
@@ -0,0 +1,54 @@
1
+ import numpy as np
2
+ import pytest
3
+
4
+ from ramansep import SeparationModel, ModeCoefficients, synthetic_demo
5
+
6
+
7
+ def test_round_trip_recovers_fields():
8
+ model = SeparationModel(synthetic_demo())
9
+ rng = np.random.default_rng(0)
10
+ strain = rng.normal(0.0, 0.1, size=(32, 32))
11
+ density = rng.normal(0.0, 1.0, size=(32, 32))
12
+ dw1, dw2 = model.forward(strain, density)
13
+ out = model.invert(dw1, dw2)
14
+ np.testing.assert_allclose(out.strain, strain, atol=1e-12)
15
+ np.testing.assert_allclose(out.density, density, atol=1e-12)
16
+
17
+
18
+ def test_uncertainty_propagation_scales_linearly():
19
+ model = SeparationModel(synthetic_demo())
20
+ out1 = model.invert(np.zeros((4, 4)), np.zeros((4, 4)), sigma1=0.1, sigma2=0.1)
21
+ out2 = model.invert(np.zeros((4, 4)), np.zeros((4, 4)), sigma1=0.2, sigma2=0.2)
22
+ np.testing.assert_allclose(out2.strain_sigma, 2.0 * out1.strain_sigma)
23
+ np.testing.assert_allclose(out2.density_sigma, 2.0 * out1.density_sigma)
24
+
25
+
26
+ def test_uncertainty_matches_monte_carlo():
27
+ model = SeparationModel(synthetic_demo())
28
+ rng = np.random.default_rng(1)
29
+ s1, s2 = 0.05, 0.08
30
+ n = 200_000
31
+ dw1 = rng.normal(0.0, s1, n)
32
+ dw2 = rng.normal(0.0, s2, n)
33
+ out = model.invert(dw1, dw2, sigma1=s1, sigma2=s2)
34
+ # analytic sigma (constant across pixels) vs empirical spread
35
+ assert np.isclose(out.strain.std(), out.strain_sigma[0], rtol=2e-2)
36
+ assert np.isclose(out.density.std(), out.density_sigma[0], rtol=2e-2)
37
+
38
+
39
+ def test_singular_matrix_rejected():
40
+ bad = ModeCoefficients("m1", "m2", 1.0, 2.0, 2.0, 4.0, reference="test")
41
+ with pytest.raises(ValueError):
42
+ SeparationModel(bad)
43
+
44
+
45
+ def test_poor_conditioning_warns():
46
+ nearly = ModeCoefficients("m1", "m2", 1.0, 1.0, 1.0, 1.001, reference="test")
47
+ with pytest.warns(UserWarning):
48
+ SeparationModel(nearly)
49
+
50
+
51
+ def test_shape_mismatch_rejected():
52
+ model = SeparationModel(synthetic_demo())
53
+ with pytest.raises(ValueError):
54
+ model.invert(np.zeros(3), np.zeros(4))
@@ -0,0 +1,95 @@
1
+ """Tests of the cited MoS2 coefficient sets.
2
+
3
+ The two headline tests reproduce, from the shipped coefficients and the
4
+ peak shifts reported in the source paper (Mahim and Rahman, under review;
5
+ tip-enhanced maps of Krayev et al., Appl. Phys. Lett. 128, 203102 (2026)),
6
+ the paper's published separation results:
7
+
8
+ * at the ribbon edge, A'1 redshifts by 0.5 cm^-1 while 2LA(M) does not
9
+ move -> an electron excess of 2.3e12 cm^-2 with strain below 0.03%;
10
+ * at an interior spot, 2LA(M) redshifts by 2.8 cm^-1 and A'1 by
11
+ 0.6 cm^-1 -> 0.134% of tension carrying no significant charge
12
+ (the paper's quoted uncertainty on the edge charge is 7.6e11 cm^-2).
13
+
14
+ If a transcription error ever enters the coefficient tables, these tests
15
+ fail against the published numbers.
16
+ """
17
+ import numpy as np
18
+ import pytest
19
+
20
+ from ramansep import SeparationModel, mos2_a1_2la, mos2_eprime_a1
21
+
22
+
23
+ def test_values_locked_a1_2la():
24
+ c = mos2_a1_2la()
25
+ assert c.mode1_name == "A'1" and c.mode2_name == "2LA(M)"
26
+ assert c.k1_strain == -5.1 # cm^-1 per % biaxial (DFT, source paper)
27
+ assert c.k1_density == -2.2 # cm^-1 per 1e13 cm^-2 (Chakraborty 2012)
28
+ assert c.k2_strain == -20.9 # cm^-1 per % biaxial (DFT, source paper)
29
+ assert c.k2_density == 0.0 # unmeasured, set to zero (documented)
30
+ assert "Chakraborty" in c.reference
31
+ assert "10.5281/zenodo.21778170" in c.reference
32
+
33
+
34
+ def test_values_locked_eprime_a1():
35
+ c = mos2_eprime_a1()
36
+ # dw/deps = -2 gamma w / 100 per percent of biaxial strain
37
+ assert c.k1_strain == pytest.approx(-2 * 0.56 * 385.0 / 100, abs=0.005)
38
+ assert c.k2_strain == pytest.approx(-2 * 0.31 * 403.0 / 100, abs=0.005)
39
+ assert c.k1_density == -0.33
40
+ assert c.k2_density == -2.2
41
+ assert "Michail" in c.reference and "Chakraborty" in c.reference
42
+
43
+
44
+ def test_lever_arm_ratio_of_paper_pair():
45
+ c = mos2_a1_2la()
46
+ # "a computed ratio of 4.1" (source paper, Sec. II)
47
+ assert c.k2_strain / c.k1_strain == pytest.approx(4.1, abs=0.05)
48
+
49
+
50
+ def test_edge_charge_reproduces_paper():
51
+ model = SeparationModel(mos2_a1_2la())
52
+ res = model.invert(np.array([-0.5]), np.array([0.0]))
53
+ density_cm2 = res.density[0] * 1e13
54
+ strain_pct = res.strain[0]
55
+ # 2LA(M) unmoved forces zero recovered strain in this pair
56
+ assert strain_pct == pytest.approx(0.0, abs=1e-12)
57
+ # exact linear inversion: 0.5 / 2.2 = 0.227e13
58
+ assert density_cm2 == pytest.approx(0.5 / 2.2 * 1e13, rel=1e-12)
59
+ # agrees with the published rounded value 2.3e12 cm^-2
60
+ assert abs(density_cm2 - 2.3e12) < 0.5e11
61
+
62
+
63
+ def test_interior_strain_reproduces_paper():
64
+ model = SeparationModel(mos2_a1_2la())
65
+ res = model.invert(np.array([-0.6]), np.array([-2.8]))
66
+ strain_pct = res.strain[0]
67
+ density_cm2 = res.density[0] * 1e13
68
+ # published: 0.134% tension
69
+ assert strain_pct == pytest.approx(0.134, abs=0.0005)
70
+ # published: no significant charge (edge-charge 1-sigma is 7.6e11)
71
+ assert abs(density_cm2) < 7.6e11
72
+
73
+
74
+ def test_optical_pair_amplifies_strain_noise_more():
75
+ """With equal shift noise, the all-optical pair is the noisier probe
76
+ of strain, because both optical modes respond weakly to strain. The
77
+ raw matrix condition number does not capture this (it is sensitive to
78
+ row scaling), so the comparison is made on the propagated sigma."""
79
+ dw = np.array([0.0])
80
+ sig = 0.1
81
+ r_paper = SeparationModel(mos2_a1_2la()).invert(dw, dw, sig, sig)
82
+ r_optical = SeparationModel(mos2_eprime_a1()).invert(dw, dw, sig, sig)
83
+ ratio = r_optical.strain_sigma[0] / r_paper.strain_sigma[0]
84
+ assert ratio > 4.0
85
+
86
+
87
+ def test_forward_inverse_roundtrip_cited_sets():
88
+ for coeffs in (mos2_a1_2la(), mos2_eprime_a1()):
89
+ model = SeparationModel(coeffs)
90
+ strain = np.array([0.05, -0.02, 0.134])
91
+ density = np.array([0.23, 0.0, 0.038])
92
+ dw1, dw2 = model.forward(strain, density)
93
+ res = model.invert(dw1, dw2)
94
+ np.testing.assert_allclose(res.strain, strain, atol=1e-12)
95
+ np.testing.assert_allclose(res.density, density, atol=1e-12)