[{"data":1,"prerenderedAt":492},["ShallowReactive",2],{"content-query-MXrPnrtVJe":3},{"_path":4,"_dir":5,"_draft":6,"_partial":6,"_locale":7,"title":8,"description":9,"date":10,"cover":11,"type":12,"category":13,"body":14,"_type":486,"_id":487,"_source":488,"_file":489,"_stem":490,"_extension":491},"/technology-blogs/zh/568","zh",false,"","技术干货| MindSpore新一代自主研发分子模拟库：Mind-Sponge","全算子化的SPONGE将与MindSpore进一步结合成为新一代端到端可微的分子模拟软件","2021-05-24","https://obs-mindspore-file.obs.cn-north-4.myhuaweicloud.com/file/2021/05/25/1e4fc3d7844047c5871d111f4aa90e0d.png","technology-blogs","大V博文",{"type":15,"children":16,"toc":483},"root",[17,25,34,39,52,63,105,112,117,122,127,132,137,142,147,180,187,192,199,204,216,226,238,245,250,263,270,275,280,285,290,302,307,317,322,329,334,342,349,354,362,369,377,382,387,394,399,407,412,417,426,433,445,450,461,466,471,476],{"type":18,"tag":19,"props":20,"children":22},"element","h1",{"id":21},"技术干货-mindspore新一代自主研发分子模拟库mind-sponge",[23],{"type":24,"value":8},"text",{"type":18,"tag":26,"props":27,"children":28},"p",{},[29],{"type":18,"tag":30,"props":31,"children":33},"img",{"alt":7,"src":32},"https://obs-mindspore-file.obs.cn-north-4.myhuaweicloud.com/file/2021/05/24/0c8eb738295d4b68afc2d5b2dca5d866.gif",[],{"type":18,"tag":26,"props":35,"children":36},{},[37],{"type":24,"value":38},"作者：于璠",{"type":18,"tag":26,"props":40,"children":41},{},[42,44],{"type":24,"value":43},"作者主页：",{"type":18,"tag":45,"props":46,"children":50},"a",{"href":47,"rel":48},"https://www.zhihu.com/people/yu-fan-42-9",[49],"nofollow",[51],{"type":24,"value":47},{"type":18,"tag":26,"props":53,"children":54},{},[55,57],{"type":24,"value":56},"原文链接：",{"type":18,"tag":45,"props":58,"children":61},{"href":59,"rel":60},"https://zhuanlan.zhihu.com/p/374219733",[49],[62],{"type":24,"value":59},{"type":18,"tag":26,"props":64,"children":65},{},[66,72,74,79,81,86,88,103],{"type":18,"tag":67,"props":68,"children":69},"strong",{},[70],{"type":24,"value":71},"MindSpore新一代分子模拟库：SPONGE",{"type":24,"value":73},"，由北大和深圳湾实验室高毅勤课题组与华为MindSpore团队联合开发，具有",{"type":18,"tag":67,"props":75,"children":76},{},[77],{"type":24,"value":78},"高性能",{"type":24,"value":80},"、",{"type":18,"tag":67,"props":82,"children":83},{},[84],{"type":24,"value":85},"模块化",{"type":24,"value":87},"等特性，是一个",{"type":18,"tag":67,"props":89,"children":90},{},[91,93,101],{"type":24,"value":92},"完全自主研发",{"type":18,"tag":67,"props":94,"children":95},{},[96],{"type":18,"tag":67,"props":97,"children":98},{},[99],{"type":24,"value":100},"的",{"type":24,"value":102},"分子模拟软件库",{"type":24,"value":104},"。基于MindSpore自动并行、图算融合等特性，SPONGE可高效地完成传统分子模拟过程，利用MindSpore自动微分的特性，可以将神经网络等AI方法与传统分子模拟进行结合。",{"type":18,"tag":26,"props":106,"children":107},{},[108],{"type":18,"tag":30,"props":109,"children":111},{"alt":7,"src":110},"https://obs-mindspore-file.obs.cn-north-4.myhuaweicloud.com/file/2021/05/24/a4d2958f77a742efb91079a72ed8bf95.png",[],{"type":18,"tag":26,"props":113,"children":114},{},[115],{"type":24,"value":116},"分子模拟是指利用计算机以原子水平的分子模型来模拟分子结构与行为，进而模拟分子体系的各种物理、化学性质的方法。它是在实验基础上，通过基本原理，构筑起一套模型和算法，从而计算出合理的分子结构与分子行为。近年来，分子模拟技术发展迅速并且在多个学科领域得到了广泛的应用。",{"type":18,"tag":26,"props":118,"children":119},{},[120],{"type":24,"value":121},"1.在药物设计领域，可用于研究病毒、药物的作用机理等；",{"type":18,"tag":26,"props":123,"children":124},{},[125],{"type":24,"value":126},"2.在生物科学领域，可用于表征蛋白质的多级结构与性质；",{"type":18,"tag":26,"props":128,"children":129},{},[130],{"type":24,"value":131},"3.在材料学领域，可用于研究结构与力学性能、材料的优化设计等；",{"type":18,"tag":26,"props":133,"children":134},{},[135],{"type":24,"value":136},"4.在化学领域，可用于研究表面催化及机理；",{"type":18,"tag":26,"props":138,"children":139},{},[140],{"type":24,"value":141},"5.在石油化工领域，可用于分子筛催化剂结构表征、合成设计、吸附扩散，可构建和表征高分子链以及晶态或非晶态本体聚合物的结构，预测包括共混行为、机械性质、扩散、内聚等重要性质。",{"type":18,"tag":26,"props":143,"children":144},{},[145],{"type":24,"value":146},"由于模拟的时空限制，传统分子动力学仿真软件的应用受到很大的限制，科研工作者需要不断地开发新的力场、抽样方法、结合新的技术(如AI算法)来拓展分子动力学仿真的场景。",{"type":18,"tag":26,"props":148,"children":149},{},[150,152,157,159,164,166,171,173,178],{"type":24,"value":151},"因此， ",{"type":18,"tag":67,"props":153,"children":154},{},[155],{"type":24,"value":156},"SPONGE应运而生",{"type":24,"value":158},"，",{"type":18,"tag":67,"props":160,"children":161},{},[162],{"type":24,"value":163},"具有完全自主的知识产权",{"type":24,"value":165},"。SPONGE使用模块化的设计特性，支持科学家进行高效且便捷地搭建分子动力学模拟中所需要的相关计算模块。同时， SPONGE也具有传统模拟所需要的高效性。除此之外，SPONGE也",{"type":18,"tag":67,"props":167,"children":168},{},[169],{"type":24,"value":170},"天然地支持与人工智能算法的自然融合",{"type":24,"value":172},"，并且能",{"type":18,"tag":67,"props":174,"children":175},{},[176],{"type":24,"value":177},"运用MindSpore框架自身的高性能计算特性",{"type":24,"value":179},"。",{"type":18,"tag":26,"props":181,"children":182},{},[183],{"type":18,"tag":30,"props":184,"children":186},{"alt":7,"src":185},"https://obs-mindspore-file.obs.cn-north-4.myhuaweicloud.com/file/2021/05/24/05f79f92d56f46f88dc1f4544a906362.png",[],{"type":18,"tag":26,"props":188,"children":189},{},[190],{"type":24,"value":191},"相比于之前在传统分子模拟软件上结合SITS方法进行生物分子增强抽样，SPONGE原生支持SITS并对计算流程进行优化使得其使用SITS方法模拟生物体系更加高效。针对极化体系，传统分子模拟采用结合量化计算等方式来解决电荷浮动等问题。即使采用机器学习降低计算量也会浪费大量时间在程序数据传送的问题上。而SPONGE利用模块化的特点可支持内存上直接与机器学习程序通信大大降低了整体计算时间。",{"type":18,"tag":26,"props":193,"children":194},{},[195],{"type":18,"tag":30,"props":196,"children":198},{"alt":7,"src":197},"https://obs-mindspore-file.obs.cn-north-4.myhuaweicloud.com/file/2021/05/24/ae00c7ed456f4596911ab3387f5dc154.jpg",[],{"type":18,"tag":26,"props":200,"children":201},{},[202],{"type":24,"value":203},"图1 结合SITS等方法对显性溶剂中的丙氨酸二肽进行增强抽样",{"type":18,"tag":26,"props":205,"children":206},{},[207,209,214],{"type":24,"value":208},"随MindSpore1.2版本开源的SPONGE具备以下",{"type":18,"tag":67,"props":210,"children":211},{},[212],{"type":24,"value":213},"优势",{"type":24,"value":215},"：",{"type":18,"tag":26,"props":217,"children":218},{},[219,224],{"type":18,"tag":67,"props":220,"children":221},{},[222],{"type":24,"value":223},"全模块化分子模拟",{"type":24,"value":225},"。模块化构建分子模拟算法，易于领域研发人员进行理论和算法的快速实现，并为外部开发人员贡献子模块提供友好的开源社区环境。",{"type":18,"tag":26,"props":227,"children":228},{},[229,231,236],{"type":24,"value":230},"传统分子模拟与MindSpore结合的",{"type":18,"tag":67,"props":232,"children":233},{},[234],{"type":24,"value":235},"人工智能算法的全流程实现",{"type":24,"value":237},"。在MindSpore中，研发人员能便利的将AI方法作用于分子模拟中。全算子化的SPONGE将与MindSpore进一步结合成为新一代端到端可微的分子模拟软件，实现人工智能与分子模拟的自然融合。",{"type":18,"tag":26,"props":239,"children":240},{},[241],{"type":18,"tag":30,"props":242,"children":244},{"alt":7,"src":243},"https://obs-mindspore-file.obs.cn-north-4.myhuaweicloud.com/file/2021/05/24/e9288c8a4a7144e5986b3bbebc7a2e34.png",[],{"type":18,"tag":26,"props":246,"children":247},{},[248],{"type":24,"value":249},"下面，这里将简单介绍一下MindSpore上的SPONGE的一个简单案例，该案例使用SPONGE模拟了丙氨酸三肽水溶液体系。",{"type":18,"tag":26,"props":251,"children":252},{},[253,255,261],{"type":24,"value":254},"实践前，确保已经正确安装MindSpore。如果没有，可以通过MindSpore安装页面(",{"type":18,"tag":45,"props":256,"children":259},{"href":257,"rel":258},"https://www.mindspore.cn/install",[49],[260],{"type":24,"value":257},{"type":24,"value":262},")安装MindSpore。",{"type":18,"tag":26,"props":264,"children":265},{},[266],{"type":18,"tag":30,"props":267,"children":269},{"alt":7,"src":268},"https://obs-mindspore-file.obs.cn-north-4.myhuaweicloud.com/file/2021/05/24/1e436bb61a0d450aa77c88c8940b7d07.png",[],{"type":18,"tag":26,"props":271,"children":272},{},[273],{"type":24,"value":274},"本教程模拟体系中需要加载三个输入文件，分别是：",{"type":18,"tag":26,"props":276,"children":277},{},[278],{"type":24,"value":279},"· 属性文件（后缀为.in的文件），声明模拟的基本条件，对整个模拟过程进行参数控制。",{"type":18,"tag":26,"props":281,"children":282},{},[283],{"type":24,"value":284},"· 拓扑文件（后缀为.param7的文件），拓扑文件描述的是体系内部分子的拓扑关系及各种参数。",{"type":18,"tag":26,"props":286,"children":287},{},[288],{"type":24,"value":289},"· 坐标文件（后缀为.rst7的文件），坐标文件描述的是每个原子在体系中的初始时刻的坐标。",{"type":18,"tag":26,"props":291,"children":292},{},[293,295],{"type":24,"value":294},"拓扑文件和坐标文件可以通过建模过程由AmberTools中自带的tleap工具建模完成，下载地址(",{"type":18,"tag":45,"props":296,"children":299},{"href":297,"rel":298},"http://ambermd.org/GetAmber.php)%E3%80%82",[49],[300],{"type":24,"value":301},"http://ambermd.org/GetAmber.php)。",{"type":18,"tag":26,"props":303,"children":304},{},[305],{"type":24,"value":306},"通过tleap构建了所需要的拓扑文件和坐标文件后，需要通过属性文件声明模拟的基本条件，对整个模拟过程进行参数控制。以本教程中的属性文件为例，其文件内容如下：",{"type":18,"tag":308,"props":309,"children":311},"pre",{"code":310},"NVT 290k\n mode = 1, # 分子动力学（MD）模式，1 表示模拟采用 NVT 系综\n dt= 0.001, # 模拟步长\n step_limit = 1, # 模拟总步数\n thermostat=1, # 控温方法，1 表示采用的是 Liujian-Langevin 方法\n langevin_gamma=1.0, # 控温器中的 Gamma_ln 参数\n target_temperature=290, # 目标温度\n write_information_interval=1000, # 输出频率\n amber_irest=0, # 输入方式，0 表示读入amber格式的输入坐标文件，其中不包含速度\n cut=10.0,  # 非键相互作用的距离\n",[312],{"type":18,"tag":313,"props":314,"children":315},"code",{"__ignoreMap":7},[316],{"type":24,"value":310},{"type":18,"tag":26,"props":318,"children":319},{},[320],{"type":24,"value":321},"案例的输入文件完成后，分别命名为 NVT_290_10ns.in 、WATER_ALA.parm7和WATER_ALA_350_cool_290.rst7，这三个文件可以存放在本地工作区的自定义路径下。",{"type":18,"tag":26,"props":323,"children":324},{},[325],{"type":18,"tag":30,"props":326,"children":328},{"alt":7,"src":327},"https://obs-mindspore-file.obs.cn-north-4.myhuaweicloud.com/file/2021/05/24/a16410dfbbae4e3082c57424a8a8e7ff.png",[],{"type":18,"tag":26,"props":330,"children":331},{},[332],{"type":24,"value":333},"从三个输入文件中，读取模拟体系所需要的参数，用于最后体系的计算，其加载代码如下：",{"type":18,"tag":308,"props":335,"children":337},{"code":336},"import argparse\nfrom mindspore import context\n \nparser = argparse.ArgumentParser(description='Sponge Controller')\nparser.add_argument('--i', type=str, default=None, help='input file')\nparser.add_argument('--amber_parm', type=str, default=None, help='paramter file in AMBER type')\nparser.add_argument('--c', type=str, default=None, help='initial coordinates file')\nparser.add_argument('--r', type=str, default=\"restrt\", help='')\nparser.add_argument('--x', type=str, default=\"mdcrd\", help='')\nparser.add_argument('--o', type=str, default=\"mdout\", help=\"\")\nparser.add_argument('--box', type=str, default=\"mdbox\", help='')\nparser.add_argument('--device_id', type=int, default=0, help='')\nargs_opt = parser.parse_args()\n \ncontext.set_context(mode=context.GRAPH_MODE, device_target=\"GPU\", device_id=args_opt.device_id, save_graphs=False)\n",[338],{"type":18,"tag":313,"props":339,"children":340},{"__ignoreMap":7},[341],{"type":24,"value":336},{"type":18,"tag":26,"props":343,"children":344},{},[345],{"type":18,"tag":30,"props":346,"children":348},{"alt":7,"src":347},"https://obs-mindspore-file.obs.cn-north-4.myhuaweicloud.com/file/2021/05/24/88dda5e2f2a64307be3bf4164a202d1e.png",[],{"type":18,"tag":26,"props":350,"children":351},{},[352],{"type":24,"value":353},"使用SPONGE中定义的计算力模块和计算能量模块，通过多次迭代进行分子动力学过程演化，使得体系达到我们所需要的平衡态，并记录每一个模拟步骤中得到的能量等数据。其模拟流程构建代码如下：",{"type":18,"tag":308,"props":355,"children":357},{"code":356},"from src.simulation_initial import Simulation\nfrom mindspore import Tensor\n \nif __name__ == \"__main__\":\n simulation = Simulation(args_opt)\n save_path = args_opt.o\n for steps in range(simulation.md_info.step_limit):\n print_step = steps % simulation.ntwx\n if steps == simulation.md_info.step_limit - 1:\n print_step = 0\n temperature, total_potential_energy, sigma_of_bond_ene, sigma_of_angle_ene, sigma_of_dihedral_ene, \\\n nb14_lj_energy_sum, nb14_cf_energy_sum, LJ_energy_sum, ee_ene, _ = simulation(Tensor(steps), Tensor(print_step))\n # compute energy and temperature\n",[358],{"type":18,"tag":313,"props":359,"children":360},{"__ignoreMap":7},[361],{"type":24,"value":356},{"type":18,"tag":26,"props":363,"children":364},{},[365],{"type":18,"tag":30,"props":366,"children":368},{"alt":7,"src":367},"https://obs-mindspore-file.obs.cn-north-4.myhuaweicloud.com/file/2021/05/24/af435e52876d45809cf38f7115bd5805.png",[],{"type":18,"tag":308,"props":370,"children":372},{"code":371},"python main.py --i /path/NVT_290_10ns.in \\\n --amber_parm /path/WATER_ALA.parm7 \\\n --c /path/WATER_ALA_350_cool_290.rst7 \\\n --o /path/ala_NVT_290_10ns.out\n",[373],{"type":18,"tag":313,"props":374,"children":375},{"__ignoreMap":7},[376],{"type":24,"value":371},{"type":18,"tag":26,"props":378,"children":379},{},[380],{"type":24,"value":381},"其中，--i 为MD模拟的属性文件，控制模拟过程，--amber_parm 为MD模拟体系的拓扑文件，--c 为我们输入的初始坐标文件，--o 为我们模拟输出的记录文件，其记录了输出每步的能量等信息，--path 为输入文件所在的路径，在本教程中为 sponge_in 文件夹。",{"type":18,"tag":26,"props":383,"children":384},{},[385],{"type":24,"value":386},"使用输入文件，通过在指定温度下进行模拟，计算力和能量，进行分子动力学过程演化。",{"type":18,"tag":26,"props":388,"children":389},{},[390],{"type":18,"tag":30,"props":391,"children":393},{"alt":7,"src":392},"https://obs-mindspore-file.obs.cn-north-4.myhuaweicloud.com/file/2021/05/24/49eff755b6854d85baec998d9e84b58f.png",[],{"type":18,"tag":26,"props":395,"children":396},{},[397],{"type":24,"value":398},"运行得到的结果在 .out 文件中，体系的能量变化都被记录在该文件中，可以查看模拟体系的热力学信息。在 .out 文件中记录了体系的如下信息：",{"type":18,"tag":308,"props":400,"children":402},{"code":401},"_steps_ _TEMP_ _TOT_POT_ENE_ _BOND_ENE_ _ANGLE_ENE_ _DIHEDRAL_ENE_ _14LJ_ENE_ _14CF_ENE_ _LJ_ENE_ _CF_PME_ENE_\n",[403],{"type":18,"tag":313,"props":404,"children":405},{"__ignoreMap":7},[406],{"type":24,"value":401},{"type":18,"tag":26,"props":408,"children":409},{},[410],{"type":24,"value":411},"其中记录了模拟过程中输出的各类能量， 分别是迭代次数（_steps_），温度（_TEMP_），总能量（_TOT_POT_E_），键长（_BOND_ENE_），键角（_ANGLE_ENE_），二面角相互作用（_DIHEDRAL_ENE_），非键相互作用，其包含静电力及Leonard-Jones相互作用。",{"type":18,"tag":26,"props":413,"children":414},{},[415],{"type":24,"value":416},"教程文档：",{"type":18,"tag":26,"props":418,"children":419},{},[420],{"type":18,"tag":45,"props":421,"children":424},{"href":422,"rel":423},"https://gitee.com/mindspore/mindscience/tree/master/MindSPONGE/mindsponge",[49],[425],{"type":24,"value":422},{"type":18,"tag":26,"props":427,"children":428},{},[429],{"type":18,"tag":30,"props":430,"children":432},{"alt":7,"src":431},"https://obs-mindspore-file.obs.cn-north-4.myhuaweicloud.com/file/2021/05/24/a552bef2f01449ef9b19002463f7fde3.png",[],{"type":18,"tag":26,"props":434,"children":435},{},[436,438,443],{"type":24,"value":437},"在MindSpore未来的版本中，会加入更多实用的分子动力学模拟模块，支持更多应用。之后，SPONGE各模块会逐步支持自动微分和自动并行，对于衔接机器学习方案提供更友好的支持。欢迎广大的分子动力学爱好者和研究者",{"type":18,"tag":67,"props":439,"children":440},{},[441],{"type":24,"value":442},"加入我们",{"type":24,"value":444},"，共同拓展和维护SPONGE。",{"type":18,"tag":26,"props":446,"children":447},{},[448],{"type":24,"value":449},"MindSpore官方资料",{"type":18,"tag":26,"props":451,"children":452},{},[453,455],{"type":24,"value":454},"GitHub : ",{"type":18,"tag":45,"props":456,"children":459},{"href":457,"rel":458},"https://github.com/mindspore-ai/mindspore",[49],[460],{"type":24,"value":457},{"type":18,"tag":26,"props":462,"children":463},{},[464],{"type":24,"value":465},"Gitee:https : //gitee.com/mindspore/mindspore",{"type":18,"tag":26,"props":467,"children":468},{},[469],{"type":24,"value":470},"官方QQ群 : 871543426",{"type":18,"tag":26,"props":472,"children":473},{},[474],{"type":24,"value":475},"长按下方二维码加入MindSpore项目↓",{"type":18,"tag":26,"props":477,"children":478},{},[479],{"type":18,"tag":30,"props":480,"children":482},{"alt":7,"src":481},"https://obs-mindspore-file.obs.cn-north-4.myhuaweicloud.com/file/2021/05/24/7a7ba86521bb454fb755729b91a856f7.jpg",[],{"title":7,"searchDepth":484,"depth":484,"links":485},4,[],"markdown","content:technology-blogs:zh:568.md","content","technology-blogs/zh/568.md","technology-blogs/zh/568","md",1776506137907]