如何存储在内存中的分子? [英] How to store molecules in memory?
问题描述
我要存储分子在内存中。这些可以是简单的分子:
I want to store molecules in memory. These can be simple molecules:
Methane (CH4)
C-H bond-length: 108.7 pm
H-H angle: 109 degrees
但也更复杂的分子,如对乙酰氨基酚(C8H9NO2):结果
But also more complex molecules, like paracetamol (C8H9NO2):
如何能存储分子在内存中,包括所有债券长度和角度?
How can I store molecules in memory, including all bond-lengths and angles?
一个好主意,存储原子结构数组中的?还是有更好的办法?
A good idea to store atom-structs in an array? Or is there a better way?
推荐答案
它看起来像某种图形数据结构:
It looks like some kind of graph data structure:
- 的分子有一组原子
- 原子被键连接:
- 的债券可以是双人,单人或特里普尔
- 债券的长度
- 债券有一个角度
通常你会存储图作为节点(原子)的阵列和边缘(债券)的数组。节点和边都希望能有指针结构。
Typically you'd store a graph as an array of nodes (atoms) and an array of edges (bonds). Nodes and edges would both be pointers to structs.
一个节点(原子)将存储的元素。
A node (atom) would store the element.
的边缘(键)将存储以下字段:
An edge (bond) would store the following fields:
- 一对指针到节点
- 该类型的债券(双/单)
- 键长和角度
因为它不是一个有向图,你的数据结构会考虑A和B之间的边缘等同于B和A也就是说,对于一个给定的原子对之间的边缘,你会期望你的优势阵列包含从A边缘到B,从来没有从B到A
Since it's not a directed graph, your data structure would consider an edge between A and B to be equivalent to an edge between B and A. That is, for a given pair of atoms, you'd expect your edge array to contain an edge from A to B and never from B to A.
这篇关于如何存储在内存中的分子?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!