This is part III of a se­ries of three posts about op­ti­miz­ing python code. The par­tic­u­lar ex­am­ple given is the com­pu­ta­tion of pair-wise dis­tances un­der pe­ri­odic bound­ary con­di­tion which is an es­sen­tial part of mol­e­c­u­lar dy­nam­ics sim­u­la­tions. In this post, I show how to use Numpy to do the com­pu­ta­tion.

This is part II of a se­ries of three posts about op­ti­miz­ing python code. The par­tic­u­lar ex­am­ple given is the com­pu­ta­tion of pair-wise dis­tances un­der pe­ri­odic bound­ary con­di­tion which is an es­sen­tial part of mol­e­c­u­lar dy­nam­ics sim­u­la­tions. In this post, I show how to use Numpy to do the com­pu­ta­tion.

In this se­ries of posts, us­ing cal­cu­la­tion of pair-wise dis­tances un­der pe­ri­odic bound­ary con­di­tion as an ex­am­ple, I show sev­eral dif­fer­ent meth­ods to op­ti­mize Python codes. The per­for­mances from dif­fer­ent meth­ods are bench­marked for com­par­i­son.

Ever won­der­ing is it pos­si­ble em­bed sci­en­tiﬁc python codes and let user in­ter­act with it di­rectly in your web­site? In this post, I demon­strate how to use Pyodide to ex­e­cute python code in­side the browser us­ing an ex­am­ple of 2D ran­dom walker.

A long time ago, I came upon hy­per.js. Before then I was us­ing the na­tive ter­mi­nal shipped with mac OS and iTerm for a long time. The aes­thet­ics of the de­sign of hy­per.js im­me­di­ately hook me. I down­loaded it and started us­ing it for my daily re­search tasks. I im­me­di­ately ﬁnd it slow. It very fre­quently gives no re­sponse to my in­put and even us­ing `ls` to list a di­rec­tory some­times can cause it to freeze for a few sec­onds. I tried to use it for prob­a­bly a month and even­tu­ally gave up. I re­sorted back to iTerm and ap­pre­ci­ated its speed which I never thought about be­fore. Although I still could­n’t ap­pre­ci­ate its de­sign at that time, its speed is fast enough to not hin­der my work in any way.

In this post, I will show how to use the API pro­vided by Netlify CMS to give the pre­view pane the abil­ity to ren­der math ex­pres­sion and high­light­ing syn­tax. The post has three parts 1) How to write a sim­ple React com­po­nent 2) How to use mark­down-it and prism.js in the tem­plate, and 3) How to pre-com­pile the tem­plate and use it

In this note, I will ac­cu­mu­late some VMD tips I ﬁnd use­ful. The main pur­pose of this note is for self con­ve­nience but I hope it can be use­ful for any­one who wan­der on this page

This note is about an ex­treme sim­ple ex­er­cise of us­ing ex­press.js and ax­ios. The pur­pose of this ex­er­cise is to learn the ba­sic con­cept of ex­press.js and ax­ios.First, I cre­ate a sim­ple ex­press server, and sec­ondly, I use ax­ios to make http call to the server cre­ated.

Simple python code for solv­ing in­te­gral equa­tion. In this ar­ti­cle, I wrote about how to solve for fred­holm in­te­gral equa­tion us­ing tikhonov reg­u­lar­iza­tion. The al­go­rithm is also pro­vided in python code.

How to map from one ma­trix to an­other us­ing deep learn­ing? This note is about the ef­fec­tive­ness of us­ing mul­ti­di­men­sional LSTM net­work to learn ma­trix op­er­a­tions, such as lin­ear map­ping as well as non-lin­ear map­ping. Recently I am try­ing to solve a re­search prob­lem re­lated to map­ping be­tween two ma­tri­ces. And came up the idea of ap­ply­ing neural net­work to the prob­lem. The Recurrent Neural Network (RNN) came to my sight not long af­ter I started search­ing

Random walks gen­er­ated in an al­ter­na­tive way and un­der­stand­ing Rouse model. Long time ago, I wrote about how to use Pivot al­go­rithm to gen­er­ate equi­lib­rium con­for­ma­tions of a ran­dom walk, ei­ther self-avoid­ing or not. The vol­ume ex­clu­sion of a self-avoid­ing chain make it non-triv­ial to gen­er­ate con­for­ma­tions. Gaussian chain, on the other hand, is very easy and triv­ial to gen­er­ate. In ad­di­tion to the ef­ﬁ­cient pivot al­go­rithm, in this ar­ti­cle, I will show an­other in­ter­est­ing but non-straight­for­ward method to gen­er­ate gauss­ian chain con­for­ma­tions

Writing a over­damped Brownian Dynamics ﬁx for LAMMPS. LAMMPS is a very pow­er­ful Molecular Dynamics sim­u­la­tion soft­ware I use in my daily re­search. In our re­search group, we mainly run Langevin Dynamics (LD) or Brownian Dynamics (BD) sim­u­la­tion. However, for some rea­son, LAMMPS does­n’t pro­vide a way to do Brownian Dynamics (BD) sim­u­la­tion. Both the LD and BD can be used to sam­ple cor­rect canon­i­cal en­sem­ble, which some­times also be called NVT en­sem­ble

Ever won­der­ing how to run a ipython note­book on a re­mote ma­chine? Here is how to do it in a sim­ple way. My re­search work in­volves a lot of us­ing of IPython Notebook. I usu­ally do it on an of­ﬁce MAC. However I also very of­ten need to ac­cess it from home. After a brief search­ing, I found these three won­der­ful ar­ti­cles on this topic

Learn how to hack your LAMMPS codes. Lessons from study­ing source codes. This is a note about learn­ing LAMMPS source codes. This note fo­cuses on com­pute style of Lammps which is used to com­pute cer­tain quan­tity dur­ing the sim­u­la­tion run. Of course you can as well com­pute these quan­ti­ties in post-process, how­ever it’s usu­ally faster to do it in the sim­u­la­tion since you can take ad­van­tage of the all the dis­tance, forces, et al gen­er­ated dur­ing the sim­u­la­tion in­stead of com­put­ing them again in post-process

Pivot al­go­rithm is best Monte Carlo al­go­rithm known so far used for gen­er­at­ing canon­i­cal en­sem­ble of self-avoid­ing ran­dom walks (ﬁxed num­ber of steps). Originally it is for the ran­dom walk on a lat­tice, but it also can be mod­i­ﬁed for con­tin­u­ous ran­dom walk. Recently I en­coun­tered a prob­lem where I need to gen­er­ate self-avoid­ing chain con­ﬁg­u­ra­tions.