# RE: Apply magnetic field through TCLBC

From: Hongbo Du (hongbodu_at_uark.edu)
Date: Mon Mar 03 2014 - 16:23:55 CST

Hi, Kenno,

Thank you very much for your suggestions.

Bests,

Hongbo
________________________________________
From: owner-namd-l_at_ks.uiuc.edu [owner-namd-l_at_ks.uiuc.edu] on behalf of Kenno Vanommeslaeghe [kvanomme_at_rx.umaryland.edu]
Sent: Monday, March 03, 2014 11:33 AM
To: namd-l_at_ks.uiuc.edu
Subject: Re: namd-l: Apply magnetic field through TCLBC

usually a good idea to dust off your old textbooks and do some back-of-the
envelope calculations on a piece of paper.

In this particular case, you could seek the answers to the following
questions:
- What kind of velocities do I expect? (hint: Maxwell–Boltzmann distribution)
- Given my magnetic field strength, what kind of forces does this yield on
my ions?
- How do these forces compare to the other forces present in the system?
(like electrostatic interactions)

But it would actually be easier to try:
- Given the m/z of my ions and my magnetic field strength, what curvature
do I expect the trajectory of my ions to undergo? (hint: often expressed
as a radius; do expect a result in macroscopic units)
- How does this curvature compare to the distance my ions travel between
collisions in my salt solution?

Or if you're not so mathematically inclined, you could try finding an old
mass spectroscopy professor and asking them what magnetic field strengths
and what radii of curvature they typically got in old-style sector
instruments.

Or you could walk to your nearest NMR lab and ask the person on duty
whether they expect ion solutions to behave chemically different in their
instruments. Though they might start talking about subtle differences in
electronic structure, which you can't capture with Molecular Mechanics anyway.

On 02/28/2014 12:22 PM, Hongbo Du wrote:
> Hi, NAMD developers and users,
>
> I am trying to simulate salt solutions with the external magnetic field through TCLBC or TCLforces. I have read out the previous and current coordinates of all the atoms and I want to use the equation F=q*(V cross B) to add a magnetic force on each atom. I specify the magnetic intensity of 0.05 T or 10 T and found that there almost doesn't exist effects on the salt solutions. I tried to use the commands loadtotalforces and loadforces available in TCLforces to check the forces I applied and the internal forces. It was found that the applied force was tiny and could be neglected. The reason is that the number of the velocity is small when velocity is obtained from the differences between the current and previous coordinates divided by timestep. Another way, Can I read out the velocity through TCLBC directly? Do you think there are some problems I may have when I add the magnetic force through TCLBC. The following is my code through TCLBC.
>
> ##################
> wrapmode cell
>
> set numatoms 6710
> # Two first agruments of calcforces are automatically forwarded
> # to it by NAMD. The other 4 arguments match the list of 4 values
> # from command tclBCArgs.
>
> for { set i 1 } { \$i <= \$numatoms } { incr i } {
> set previouscoorx(\$i) 0
> set previouscoory(\$i) 0
> set previouscoorz(\$i) 0
> }
> #for { set i 1 } { \$i <= \$numatoms } { incr i } { print "previous \$previouscoor(\$i)" }
> proc calcforces { step unique } {
>
> global forceunit charge mfield diffcoord atomnumber
> global previouscoorx previouscoory previouscoorz
>
> set frametime 0.000000000000002
> set forceunit 6.948E-11
> set mfield "0.05 0 0"
>
> if { \$step == 1 } {
> while {[nextatom]} {
> set atomnumber [getid]
> set rvec [getcoord]
> foreach {x y z} \$rvec { break }
> set previouscoorx(\$atomnumber) \$x
> set previouscoory(\$atomnumber) \$y
> set previouscoorz(\$atomnumber) \$z
> # print "\$atomnumber test x \$previouscoorx(\$atomnumber)"
> }
> # print "step \$step"
> }
> if { \$step >= 2 } {
> while {[nextatom]} {
> set atomnumber [getid]
> set charge [getcharge]
> set rvec [getcoord]
> set tmpcharge [expr \$charge*1.602176565E-19]
> set mfieldx [lindex \$mfield 0]
> set mfieldy [lindex \$mfield 1]
> set mfieldz [lindex \$mfield 2]
> foreach {currentx currenty currentz} \$rvec { break }
> set currentvx [expr (\$currentx-\$previouscoorx(\$atomnumber))*1.0E-10/\$frametime]
> set currentvy [expr (\$currenty-\$previouscoory(\$atomnumber))*1.0E-10/\$frametime]
> set currentvz [expr (\$currentz-\$previouscoorz(\$atomnumber))*1.0E-10/\$frametime]
> set mforcex [expr \$tmpcharge*[expr \$mfieldy*\$currentvz-\$mfieldz*\$currentvy]/\$forceunit]
> set mforcey [expr \$tmpcharge*[expr -\$mfieldx*\$currentvz+\$mfieldz*\$currentvx]/\$forceunit]
> set mforcez [expr \$tmpcharge*[expr \$mfieldx*\$currentvy-\$mfieldy*\$currentvx]/\$forceunit]
> if { (\$atomnumber==6710) && ( \$step%100==0) } {
> print "atom \$atomnumber previous \$previouscoorx(\$atomnumber) \$previouscoory(\$atomnumber) \$previouscoorz(\$atomnumber)"
> print "atom \$atomnumber current \$currentx \$currenty \$currentz "
> print "velocity \$currentvx \$currentvy \$currentvz"
> print "step \$step atom \$atomnumber \$mforcex \$mforcey \$mforcez"
> }
> set previouscoorx(\$atomnumber) \$currentx
> set previouscoory(\$atomnumber) \$currenty
> set previouscoorz(\$atomnumber) \$currentz
>
> }
> #print "step \$step"
> }
>
> while {[nextatom]} {
> }
> }
> ########################
>
>
> Best wishes,
>
> Dr. Hongbo Du
>
> Postdoc fellow at University of Arkansas
>
>
>
>
>
>
>
>

This archive was generated by hypermail 2.1.6 : Thu Dec 31 2015 - 23:20:34 CST