如何将分子存储在记忆体中? [英] How to store molecules in memory?

查看:173
本文介绍了如何将分子存储在记忆体中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想将分子存储在记忆体中。这些可以是简单的分子:

 甲烷(CH4)
CH债券长度:108.7 pm
HH角度:109度

而且更复杂的分子,如扑热息痛(C8H9NO2):



如何将分子存储在记忆,包括所有的债券长度和角度?






一个好主意,将atom-struct存储在数组中?还是有更好的方法?

解决方案

它看起来像某种图形数据结构:




  • 一个分子有一组原子

  • 原子由债券链接:


    • 债券可以是双倍,单一或三倍

    • 债券的长度

    • 债券有一个角度


  • 这是一个循环图(例如,问题中的例子有一个交替的单键和双键)

  • 它不是一个有向图(如果两个原子相互抵触,那么你接近债券就不重要)



通常,您将图形存储为一个节点数(原子)和边缘数组(bond)。节点和边缘都是指向结构体的指针。



节点(atom)将存储元素。



边缘(债券)将存储以下字段:




  • 一个指向节点的指针

  • 债券类型(双/单)

  • 债券长度和角度



既然是您的数据结构不是有向图,您的数据结构将考虑A和B之间的边缘等于B和A之间的边。也就是说,对于给定的原子对,您会希望边缘数组包含来自A的边到B,从不从B到A。


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

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:

  • A molecule has a set of atoms
  • Atoms are linked by bonds:
    • A bond can be double, single or tripple
    • A bond has a length
    • A bond has an angle
  • It's a cyclic graph (for instance, the example in the question has a ring of alternating single and double bonds)
  • It's not a directed graph (if two atoms are bonded, it doesn't matter from which end you approach the bond)

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 pair of pointers to nodes
  • The type of bond (double/single)
  • The bond length and angle

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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆