How to get a node model from edge model

Hello, Juan!
I want to ask is there a way to get a node model from edge model? Or can I get the node_index of corresponding edge?

Hi @ghost

If you use this command you can get the node index for each edge:

edge_from_node_model(node_model="node_index", device=device, region=region)

which would create the node_index@n0 and node_index@n1 model. You can then convert these indexes to integer so you can index them in your scripts.

ni0 = [int(x) for x in devsim.get_edge_model_values(device=device, region=region, name="node_index@n0")]
ni1 = [int(x) for x in devsim.get_edge_model_values(device=device, region=region, name="node_index@n1")]

This works well for post processing. If you want this to be part of a model assembly, please let me know and we can discuss those options.

Thank you for your help! This is what I need. I still have a question that whether the “node_index@n0” and “node_index@n1” are in order. Which means the first point of “node_index@n0” and the first point of “node_index@n1” exactly form the first edge (whose index is 0). And similar in other point and edge?
I need output some edge data to calculate in other program, but the edge_model is hard use to me. So I want to transfer them to a node model and use the middle point of edge to approximate. For now, use above commend is enough for me to code. But if some users also need this function, it is a good idea to build a model for that!

Hi @ghost

It is possible to get the midpoint of edges using:
https://devsim.net/CommandReference.html#devsim.edge_average_model

edge_average_model(device=device, region=region, node_model="x", edge_model="xmid", average_type="arithmetic")
edge_average_model(device=device, region=region, node_model="y", edge_model="ymid", average_type="arithmetic")

Also the unitx and unity edge models give the unit vector components from node 0 to node 1.

Thank you, Juan! It do me a favor.