VMD-L Mailing List
From: Nakshatra Upadhyay (1225nakshatraupadhyay1975_at_gmail.com)
Date: Mon Jan 13 2025 - 14:05:31 CST
- Next message: Giacomo Fiorin: "Re: Applying electric field only on ions"
- Previous message: Shirin: "MDFF with rRNA modifications"
- Next in thread: Giacomo Fiorin: "Re: Applying electric field only on ions"
- Reply: Giacomo Fiorin: "Re: Applying electric field only on ions"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ] [ attachment ]
Dear all,
I want to perform an applied electric field simulation of a system
consisting of a transmembrane channel. I want to apply the electric field
only on the ions, i.e., potassium and chloride. I understand that I have to
use tclforce option for that.
I tried to write the following code, but it showed
FATAL ERROR: Setting parameter tclForces from script failed!
"
tclForcesScript {
# Parameters for the electric field
set efield {0.0 0.0 0.603393} ;# Electric field in kcal/mol·Å·e
# Atom selection: Read target atoms from the PDB file
set targetMark "1.00"
set targetAtomPdb "KCl.pdb"
set targets {}
set atoms {}
# Open and process the PDB file
set inStream [open $targetAtomPdb r]
foreach line [split [read $inStream] \n] {
if {([string equal [string range $line 0 4] "ATOM"] || \
[string equal [string range $line 0 4] "HETA"]) && \
[string equal [string trim [string range $line 54 59]]
$targetMark]} {
set segname [string trim [string range $line 72 75]]
set resid [string trim [string range $line 22 25]]
set atomname [string trim [string range $line 12 15]]
lappend targets "$segname $resid $atomname"
}
}
close $inStream
# Convert targets to atom indices
foreach target $targets {
foreach {segname resid atomname} $target { break }
set atomIndex [atomid $segname $resid $atomname]
lappend atoms $atomIndex
addatom $atomIndex
}
# Check if any atoms were selected
if {[llength $atoms] == 0} {
print "ERROR: No target atoms detected."
return
}
# Procedure to apply electric field forces
proc calcforces { } {
global atoms efield
# Extract electric field components
foreach {ex ey ez} $efield { break }
# Apply force to each atom
foreach atom $atoms {
set charge [atom charge $atom]
set Fx [expr $charge * $ex]
set Fy [expr $charge * $ey]
set Fz [expr $charge * $ez]
addforce $atom $Fx $Fy $Fz
}
}
# Register the force calculation procedure
runforces calcforces
}
"
Could you please advise me on how to proceed?
Best regards,
Nakshatra
- Next message: Giacomo Fiorin: "Re: Applying electric field only on ions"
- Previous message: Shirin: "MDFF with rRNA modifications"
- Next in thread: Giacomo Fiorin: "Re: Applying electric field only on ions"
- Reply: Giacomo Fiorin: "Re: Applying electric field only on ions"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ] [ attachment ]