vgsot-sim 0.1.0__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.
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,384 @@
1
+ Metadata-Version: 2.4
2
+ Name: vgsot-sim
3
+ Version: 0.1.0
4
+ Summary: VGSOT/SOT MTJ switching simulation (electronic + anisotropy + LLG step solver)
5
+ Author: Jincheng Zhang
6
+ License: MIT
7
+ Project-URL: Repository, https://github.com/JinChengZ18/vgsot-sim/tree/main
8
+ Keywords: spintronics,mtj,simulation,vgsot,sot-mram
9
+ Classifier: Programming Language :: Python :: 3
10
+ Classifier: Programming Language :: Python :: 3 :: Only
11
+ Classifier: License :: OSI Approved :: MIT License
12
+ Classifier: Operating System :: OS Independent
13
+ Requires-Python: >=3.9
14
+ Description-Content-Type: text/markdown
15
+ License-File: LICENSE
16
+ Requires-Dist: numpy>=1.22
17
+ Requires-Dist: matplotlib>=3.6
18
+ Requires-Dist: tqdm>=4.64
19
+ Provides-Extra: dev
20
+ Requires-Dist: pytest>=7; extra == "dev"
21
+ Requires-Dist: ruff>=0.4; extra == "dev"
22
+ Dynamic: license-file
23
+
24
+ # vgsot-sim
25
+
26
+ A physics-based simulation toolkit for **VGSOT-MTJ (Voltage-Gated Spin-Orbit Torque Magnetic Tunnel Junction) and SOT-MTJ** switching dynamics.
27
+
28
+ The simulator couples several physical effects into a time-domain switching model:
29
+
30
+ - Electronic transport (`V_MTJ`, `I_SOT`)
31
+ - Voltage-controlled magnetic anisotropy (**VCMA**)
32
+ - Thermal fluctuation field
33
+ - Analytical one-step **LLG magnetization update**
34
+ - **TMR resistance feedback**
35
+
36
+ This enables simulation of magnetization switching under realistic electrical excitation waveforms.
37
+
38
+ The package can be used either:
39
+
40
+ - as a **command-line simulator**
41
+ - as a **Python simulation library**
42
+
43
+
44
+
45
+ ---
46
+
47
+ ## Installation
48
+
49
+ Clone the repository and install in editable mode:
50
+
51
+ ```bash
52
+ pip install -e .
53
+ ```
54
+
55
+ Requirements (automatically installed):
56
+
57
+ - numpy
58
+ - matplotlib
59
+ - tqdm
60
+
61
+
62
+
63
+ ---
64
+
65
+ ## Information flow
66
+
67
+ ```mermaid
68
+ flowchart LR
69
+ classDef io fill:#f5f3ff,stroke:#7c3aed,stroke-width:1.2px,color:#111;
70
+ classDef case fill:#f3e8ff,stroke:#9333ea,stroke-width:1.2px,color:#111;
71
+ classDef kernel fill:#ede9fe,stroke:#7c3aed,stroke-width:1.2px,color:#111;
72
+ classDef out fill:#faf5ff,stroke:#a855f7,stroke-width:1.2px,color:#111;
73
+
74
+ CLI["CLI / Config"]:::io
75
+ CASE["Selected case<br/>(time-series / SER)"]:::case
76
+
77
+ INIT["initialize.py<br/>initial state"]:::kernel
78
+ ELEC["electronic.py<br/>current / voltage mapping"]:::kernel
79
+ DYN["dynamic_switching.py<br/>magnetization update"]:::kernel
80
+ ANI["anisotropy.py<br/>effective field"]:::kernel
81
+ STO["stochastic.py<br/>thermal noise"]:::kernel
82
+ TMR["tmr.py<br/>resistance feedback"]:::kernel
83
+
84
+ RES["SimResult / SweepResult /<br/>SerResult"]:::out
85
+ SAVE["result_io.py<br/>CSV / plot export"]:::out
86
+
87
+ CLI --> CASE
88
+ CASE --> INIT
89
+ CASE --> ELEC
90
+ CASE --> DYN
91
+ DYN --> ANI
92
+ ANI --> STO
93
+ DYN --> TMR
94
+
95
+ INIT --> CASE
96
+ ELEC --> CASE
97
+ DYN --> CASE
98
+ TMR --> CASE
99
+
100
+ CASE --> RES
101
+ RES --> SAVE
102
+ ```
103
+
104
+ This structure separates **physics kernels**, **experiment orchestration**, and **output utilities**, making the project usable both as a CLI simulator and as a reusable Python library.
105
+
106
+ For more details, please refer to: [Project structure](docs/structure.md)
107
+
108
+
109
+
110
+
111
+ ---
112
+
113
+ ## Running Simulation Cases
114
+
115
+ All experiments are exposed through a unified CLI:
116
+
117
+ ```
118
+ vgsot-sim <case_name>
119
+ ```
120
+
121
+ By default, outputs are written to:
122
+
123
+ - `./result/*.png` (figures)
124
+ - `./result/*.csv` (time series / sweep results)
125
+
126
+ You can change output directory via:
127
+
128
+ ```
129
+ vgsot-sim <case_name> --out_dir my_results
130
+ ```
131
+
132
+ Disable progress bars:
133
+
134
+ ```
135
+ vgsot-sim <case_name> --no_progress
136
+ ```
137
+
138
+ ### Available cases
139
+
140
+ You can run all cases below (names match `src/vgsot_sim/cli.py`):
141
+
142
+ ```
143
+ # 1) Three-terminal voltage control (V1,V2,V3 -> I_SOT,V_MTJ)
144
+ vgsot-sim terminal_voltage_control
145
+
146
+ # 2) Baseline: SOT-only, constant current pulse (V_MTJ=0)
147
+ vgsot-sim sot_only_constant_current
148
+
149
+ # 3) No-VCMA SOT switching: sweep I_SOT and overlay mz(t)
150
+ vgsot-sim sot_switching_no_vcma
151
+
152
+ # 4) SER vs I_SOT: no-VCMA + thermal noise (Monte-Carlo)
153
+ vgsot-sim ser_sot_no_vcma_thermal
154
+
155
+ # 5) VCMA-assisted: fix V_MTJ, sweep I_SOT and overlay mz(t)
156
+ vgsot-sim vcma_assisted_switching_isot_sweep
157
+
158
+ # 6) VCMA-assisted: fix I_SOT, sweep V_MTJ and overlay mz(t)
159
+ vgsot-sim vcma_assisted_switching_vmtj_sweep
160
+
161
+ # 7) optimized two-pulse scheme: sweep (t1,t2) and overlay mz(t)
162
+ vgsot-sim optimized_vgsot_switching
163
+
164
+ # 8) SER vs t1 for optimized scheme: thermal noise (Monte-Carlo)
165
+ vgsot-sim ser_optimized_vgsot
166
+ ```
167
+
168
+ For more information, please refer to: [Simulation Cases and Their Physical Meaning](docs/cases.md)
169
+
170
+ Default parameters are listed in: [Default parameters by case](docs/parameters.md)
171
+
172
+
173
+
174
+ ---
175
+
176
+ ## Using as a Python library (recommended)
177
+
178
+ Besides running from command line, you can **import and run each case directly in your own Python scripts**, and override parameters as needed. The recommended workflow is:
179
+
180
+ 1. Create a **configuration dataclass**
181
+ 2. Run a **simulation case**
182
+ 3. Optionally save results using `result_io`
183
+
184
+ ---
185
+
186
+ ### 1. Basic Python API usage
187
+
188
+ Quick start (minimal example)
189
+
190
+ ```python
191
+ from vgsot_sim import sot_only_constant_current
192
+
193
+ res = sot_only_constant_current()
194
+ print(res.mz[-1])
195
+ ```
196
+
197
+ Example: run a VCMA-assisted switching simulation.
198
+
199
+ ```python
200
+ from vgsot_sim import (
201
+ vcma_assisted_switching_isot_sweep,
202
+ VcmaAssistedSwitchingIsotSweepConfig,
203
+ )
204
+
205
+ cfg = VcmaAssistedSwitchingIsotSweepConfig(
206
+ v_mtj=1.1,
207
+ i_sot_list=[-40e-6, -30e-6, -20e-6],
208
+ )
209
+
210
+ result = vcma_assisted_switching_isot_sweep(cfg)
211
+
212
+ print(result.time_s.shape)
213
+
214
+ print(result.mz_curves.keys())
215
+ print(result.r_mtj_curves.keys())
216
+ print(result.pulse_curves.keys())
217
+ ```
218
+
219
+ Returned object:
220
+
221
+ | field | type | description |
222
+ | ----------------- | ----------------------- | -------------------------- |
223
+ | `time_s` | `np.ndarray` | simulation time axis |
224
+ | `mz_curves` | `dict[str, np.ndarray]` | magnetization trajectories |
225
+ | `r_mtj_curves` | `dict[str, np.ndarray]` | MTJ resistance vs time |
226
+ | `pulse_curves` | `dict[str, np.ndarray]` | applied pulse waveform |
227
+ | `switch_energy_j` | `dict[str, float]` | switching energy |
228
+ | `pulse_ylabel` | `str` | label for pulse plot |
229
+
230
+ Each entry in `curves` corresponds to one sweep parameter.
231
+
232
+ ------
233
+
234
+ ### 2. plotting results (optional)
235
+
236
+ ```python
237
+ import matplotlib.pyplot as plt
238
+
239
+ for label, mz in result.mz_curves.items():
240
+ plt.plot(result.time_s, mz, label=label)
241
+
242
+ plt.xlabel("time (s)")
243
+ plt.ylabel("mz")
244
+ plt.legend()
245
+ plt.show()
246
+ ```
247
+
248
+ ------
249
+
250
+ ### 3. Running Monte-Carlo SER simulations
251
+
252
+ Example:
253
+
254
+ ```python
255
+ from vgsot_sim import (
256
+ ser_sot_no_vcma_thermal,
257
+ SerSotNoVcmaThermalConfig,
258
+ )
259
+
260
+ cfg = SerSotNoVcmaThermalConfig(
261
+ trials=500,
262
+ i_sot_list=[-100e-6, -95e-6, -90e-6],
263
+ )
264
+
265
+ res = ser_sot_no_vcma_thermal(cfg)
266
+
267
+ print(res.x) # I_SOT values
268
+ print(res.ser) # switching error rate
269
+ ```
270
+
271
+ Returned object:
272
+
273
+ ```
274
+ SerResult
275
+ ├── x : ndarray
276
+ ├── ser : ndarray
277
+ └── x_label : str
278
+ ```
279
+
280
+ ------
281
+
282
+ ### 4. Low-level simulation kernels (advanced users)
283
+
284
+ If you want full control over excitation waveforms, you can call the internal kernels directly:
285
+
286
+ ```
287
+ run_piecewise_terminal_voltage(...)
288
+ run_piecewise_direct_excitation(...)
289
+ run_two_pulse_proposed(...)
290
+ ```
291
+
292
+ Example:
293
+
294
+ ```python
295
+ from vgsot_sim import run_piecewise_direct_excitation
296
+
297
+ res = run_piecewise_direct_excitation(
298
+ sim_start_step=1,
299
+ sim_mid1_step=2000,
300
+ sim_mid2_step=3500,
301
+ sim_end_step=5000,
302
+
303
+ pap=1,
304
+
305
+ v_mtj_stage1=0.0,
306
+ v_mtj_stage2=0.0,
307
+ v_mtj_stage3=0.0,
308
+
309
+ i_sot_stage1=-90e-6,
310
+ i_sot_stage2=0.0,
311
+ i_sot_stage3=0.0,
312
+
313
+ estt_stage1=0,
314
+ esot_stage1=1,
315
+
316
+ estt_stage2=0,
317
+ esot_stage2=1,
318
+
319
+ estt_stage3=0,
320
+ esot_stage3=1,
321
+
322
+ vnv=1,
323
+ non=1,
324
+
325
+ r_sot_fl_dl=0.83,
326
+ )
327
+
328
+ print(res.time_s)
329
+ print(res.mz)
330
+ ```
331
+
332
+ These kernels return a `SimResult` dataclass containing the full time evolution of the system.
333
+
334
+ For full API documentation, please refer to: [API document](docs/api.md)
335
+
336
+ For more detailed API usage, please refer to: [CASES GUIDE](notebooks/docs_cases_notebook.ipynb)
337
+
338
+
339
+
340
+ ------
341
+
342
+ ### Notes
343
+
344
+ - `I_SOT` units: **Ampere**
345
+ - `V_MTJ` units: **Volt**
346
+ - time units: **seconds**
347
+
348
+ The simulation time step is defined in:
349
+
350
+ ```
351
+ vgsot_sim/constants.py
352
+ ```
353
+
354
+ via:
355
+
356
+ ```
357
+ constants.t_step
358
+ ```
359
+
360
+ For reproducible Monte-Carlo runs:
361
+
362
+ ```
363
+ import numpy as np
364
+ np.random.seed(0)
365
+ ```
366
+
367
+
368
+
369
+ ---
370
+
371
+ ## Citation
372
+
373
+ If you use this simulator in academic research, please cite:
374
+
375
+ ```
376
+ Zhang Jincheng. (2026). VGSOT-SIM: A VGSOT switching simulation toolkit [Computer software]. GitHub.
377
+ ```
378
+
379
+ For more technical details, please refer to: [Technical Details](docs/technical_details.md)
380
+
381
+
382
+
383
+
384
+