mnns.nanowire_network
¶
Functions to create nanowire networks.
Classes:
| Name | Description |
|---|---|
NanowireNetwork |
Internal nanowire network object. Should not be instantiated directly. |
ParameterNotSetError |
Raised when an parameter that needs to used has not been set yet. |
Functions:
| Name | Description |
|---|---|
create_NWN |
Create a nanowire network represented by a NetworkX graph. Wires are |
NanowireNetwork
¶
NanowireNetwork(incoming_graph_data=None, **attr)
Bases: Graph
Internal nanowire network object. Should not be instantiated directly.
Use mnns.create_NWN
instead.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
incoming_graph_data
|
input graph
|
Data to initialize graph. Same as networkx.Graph object. |
None
|
**attr
|
Keyword arguments. Same as networkx.Graph object. |
{}
|
Methods:
| Name | Description |
|---|---|
evolve |
Evolve the nanowire network using the given model and state variables. |
get_index |
Return the unique index of a node in the network. |
get_index_from_edge |
Return the indices of the nodes in the edge as a tuple. |
get_node |
Return the node corresponding to the index. |
get_state_var |
Get the state variable of the memristors (nanowire network wire |
set_state_var |
Set the state variable of the memristors (nanowire network wire |
to_MNR |
Converts the NWN to the multi-nodal representation (MNR). |
update_resistance |
Update the resistance of the nanowire network based on the provided |
wire_junction_indices |
Return the start and end indices of the wire junctions in the network |
Attributes:
| Name | Type | Description |
|---|---|---|
lines |
list[LineString]
|
List of LineStrings representing the nanowires. Includes electrodes. |
loc |
dict[tuple[int, int], Point]
|
Dictionary of graph edge locations (nanowire junctions). Only |
n_wires |
int
|
Number of wires in the network. Does not include electrodes. |
resistance_function |
Callable[[NanowireNetwork, ArrayLike], ArrayLike]
|
Resistance function of the nanowire network. Should have the calling |
wire_density |
float
|
Wire density in units of (l0)^-2. Does not include electrodes. |
wire_junctions |
list[NWNEdge]
|
Return a list of edges with the "type" attribute set to "junction". |
Source code in mnns/nanowire_network.py
66 67 68 69 70 71 | |
lines
property
¶
lines: list[LineString]
List of LineStrings representing the nanowires. Includes electrodes.
loc
property
¶
loc: dict[tuple[int, int], Point]
Dictionary of graph edge locations (nanowire junctions). Only represents anything meaningful for JDA NWNs. MNR NWNs do not update this value. Indexes with a NWNEdge but without the nested tuples.
Does not have a guaranteed ordering.
resistance_function
property
writable
¶
resistance_function: Callable[
[NanowireNetwork, ArrayLike], ArrayLike
]
Resistance function of the nanowire network. Should have the calling
signature func(NWN, param1, [param2, ...]) where NWN is the
nanowire network, and param1, param2, etc. are the state variables
of the memristor element(s).
You can also pass the string "linear" to choose a default linear resistance function based on the state variable x in [0, 1].
The resistance should be nondimensionalized, i.e. the resistance should be in units of Ron.
wire_density
property
¶
wire_density: float
Wire density in units of (l0)^-2. Does not include electrodes.
wire_junctions
deletable
property
¶
wire_junctions: list[NWNEdge]
Return a list of edges with the "type" attribute set to "junction". Once called, the list is cached so the ordering can be fixed. If wires are added, clear the cache by deleting the property.
evolve
¶
evolve(
model: Callable[..., ArrayLike],
t_eval: NDArray,
args: tuple[Any, ...] = (),
state_vars: Optional[list[str]] = None,
ivp_options: dict = {},
) -> OdeResult
Evolve the nanowire network using the given model and state variables. Returns the solution of the initial value problem solver from scipy at the given time points.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
model
|
callable
|
Model to use for the evolution. Should be a function with the
signature |
required |
t_eval
|
ndarray
|
Time points to evaluate the solution at. |
required |
state_vars
|
list of str
|
List of state variables to evolve. If not provided, all
state variables in |
None
|
args
|
tuple
|
Additional arguments to pass to the model function. Most likely, you will need to provide args for the source node(s), drain node(s) and voltage function. |
()
|
ivp_options
|
dict
|
Additional keyword arguments to pass to the IVP solver. |
{}
|
Source code in mnns/nanowire_network.py
374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 | |
get_index
¶
get_index(node: NWNNode | list[NWNNode]) -> NWNNodeIndex
Return the unique index of a node in the network.
Source code in mnns/nanowire_network.py
129 130 131 | |
get_index_from_edge
¶
get_index_from_edge(
edge: NWNEdge | list[NWNEdge],
) -> NWNEdgeIndex | list[NWNEdgeIndex]
Return the indices of the nodes in the edge as a tuple.
Source code in mnns/nanowire_network.py
142 143 144 145 146 147 148 149 | |
get_node
¶
get_node(index: NWNNodeIndex) -> NWNNode
Return the node corresponding to the index.
Source code in mnns/nanowire_network.py
133 134 135 136 137 138 139 140 | |
get_state_var
¶
get_state_var(
var_name: str, edge_list: list[NWNEdge] | None = None
) -> npt.ArrayLike
Get the state variable of the memristors (nanowire network wire junctions) in the network.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
var_name
|
str
|
Name of the state variable(s) to get. |
required |
edge_list
|
list of edges
|
List of edges to get the state variable from. If None, all wire junction edges will be used. |
None
|
Returns:
| Type | Description |
|---|---|
ndarray or scalar
|
Value of the state variable(s). |
Source code in mnns/nanowire_network.py
284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 | |
set_state_var
¶
set_state_var(
var_name: str,
value: ArrayLike,
edge_list: list[NWNEdge] | None = None,
) -> None
Set the state variable of the memristors (nanowire network wire junctions) in the network.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
var_name
|
str
|
Name of the state variable(s) to set. |
required |
value
|
ndarray or scalar
|
Value to set the state variable(s) to. |
required |
edge_list
|
list of edges
|
List of edges to set the state variable for. If None, all wire junction edges will be used. Should be the same length as the value array. |
None
|
Source code in mnns/nanowire_network.py
226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 | |
to_MNR
¶
to_MNR() -> None
Converts the NWN to the multi-nodal representation (MNR).
Source code in mnns/nanowire_network.py
151 152 153 | |
update_resistance
¶
update_resistance(
state_var_vals: ArrayLike | list[ArrayLike],
edge_list: list[NWNEdge] | None = None,
) -> None
Update the resistance of the nanowire network based on the provided state variable values. The resistance function should be set before calling this method.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
state_var_vals
|
ndarray or list of ndarrays
|
An array of values of the state variables to use in the resistance
function. The should be in the same order as the state variables.
If the resistance function takes multiple state variables, pass a
list of arrays in the same order as |
required |
edge_list
|
list of edges
|
List of edges to update the resistance for. If None, all wire
junction edges will be used. In this case, the length of the
|
None
|
Returns:
| Type | Description |
|---|---|
ndarray
|
Array of updated resistance values for each edge in the edge_list. |
Source code in mnns/nanowire_network.py
325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 | |
wire_junction_indices
cached
¶
wire_junction_indices() -> (
tuple[list[NWNNodeIndex], list[NWNNodeIndex]]
)
Return the start and end indices of the wire junctions in the network as a tuple of lists.
Source code in mnns/nanowire_network.py
177 178 179 180 181 182 183 184 185 186 | |
ParameterNotSetError
¶
ParameterNotSetError(
message: str, param: Any | None = None
)
Bases: Exception
Raised when an parameter that needs to used has not been set yet.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
param
|
str
|
Name of the parameter that needs to be set. |
None
|
message
|
str
|
Explanation of the error. |
required |
Source code in mnns/nanowire_network.py
45 46 47 | |
create_NWN
¶
create_NWN(
wire_length: float = 7.0 / 7,
shape: tuple[float, float] = (50.0 / 7, 50.0 / 7),
density: float = 0.3 * 7**2,
seed: int = None,
conductance: float = 0.1 / 0.1,
capacitance: float = 1000,
diameter: float = 50.0 / 50.0,
resistivity: float = 22.6 / 22.6,
units: dict[str, float] = None,
angle_dist: str = "uniform",
angle_kwargs: dict | None = None,
) -> NanowireNetwork
Create a nanowire network represented by a NetworkX graph. Wires are represented by the graph's vertices, while the wire junctions are represented by the graph's edges.
The nanowire network starts in the junction-dominated assumption (JDA), but can be converted to the multi-nodal representation (MNR) after creation.
The desired density may not be attainable with the given shape, as there can only be a integer number of wires. Thus, the closest density to an integer number of wires is used and stored as an attribute (see NWN Attributes for more information).
See mnns.NWNUnits for the units used by
the parameters.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
wire_length
|
float
|
Length of each nanowire. Given in units of l0. |
7.0 / 7
|
shape
|
2-tuple of float
|
The shape of the nanowire network given in units of l0. Assumed to have the shape of (x-length, y-length). The x direction is labeled |
(50.0 / 7, 50.0 / 7)
|
density
|
float
|
Density of nanowires in the area determined by the width. Given in units of (l0)^-2. |
0.3 * 7 ** 2
|
seed
|
int
|
Seed for random nanowire generation. |
None
|
conductance
|
float
|
The junction conductance of the nanowires where they intersect. Given in units of (Ron)^-1. |
0.1 / 0.1
|
capacitance
|
float
|
The junction capacitance of the nanowires where they intersect. Given in microfarads. (Currently unused) |
1000
|
diameter
|
float
|
The diameter of each nanowire. Given in units of D0. |
50.0 / 50.0
|
resistivity
|
float
|
The resistivity of each nanowire. Given in units of rho0. |
22.6 / 22.6
|
units
|
dict
|
Dictionary of custom base units. Defaults to None which will use the
default units given in |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
NWN |
Graph
|
The created random nanowire network. |
Source code in mnns/nanowire_network.py
466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 | |