source: utils/developer/tcl/animatesphere.tcl@ 321470

Action_Thermostats Add_AtomRandomPerturbation Add_FitFragmentPartialChargesAction Add_RotateAroundBondAction Add_SelectAtomByNameAction Added_ParseSaveFragmentResults AddingActions_SaveParseParticleParameters Adding_Graph_to_ChangeBondActions Adding_MD_integration_tests Adding_ParticleName_to_Atom Adding_StructOpt_integration_tests AtomFragments Automaking_mpqc_open AutomationFragmentation_failures Candidate_v1.5.4 Candidate_v1.6.0 Candidate_v1.6.1 ChangeBugEmailaddress ChangingTestPorts ChemicalSpaceEvaluator CombiningParticlePotentialParsing Combining_Subpackages Debian_Package_split Debian_package_split_molecuildergui_only Disabling_MemDebug Docu_Python_wait EmpiricalPotential_contain_HomologyGraph EmpiricalPotential_contain_HomologyGraph_documentation Enable_parallel_make_install Enhance_userguide Enhanced_StructuralOptimization Enhanced_StructuralOptimization_continued Example_ManyWaysToTranslateAtom Exclude_Hydrogens_annealWithBondGraph FitPartialCharges_GlobalError Fix_BoundInBox_CenterInBox_MoleculeActions Fix_ChargeSampling_PBC Fix_ChronosMutex Fix_FitPartialCharges Fix_FitPotential_needs_atomicnumbers Fix_ForceAnnealing Fix_IndependentFragmentGrids Fix_ParseParticles Fix_ParseParticles_split_forward_backward_Actions Fix_PopActions Fix_QtFragmentList_sorted_selection Fix_Restrictedkeyset_FragmentMolecule Fix_StatusMsg Fix_StepWorldTime_single_argument Fix_Verbose_Codepatterns Fix_fitting_potentials Fixes ForceAnnealing_goodresults ForceAnnealing_oldresults ForceAnnealing_tocheck ForceAnnealing_with_BondGraph ForceAnnealing_with_BondGraph_continued ForceAnnealing_with_BondGraph_continued_betteresults ForceAnnealing_with_BondGraph_contraction-expansion FragmentAction_writes_AtomFragments FragmentMolecule_checks_bonddegrees GeometryObjects Gui_Fixes Gui_displays_atomic_force_velocity ImplicitCharges IndependentFragmentGrids IndependentFragmentGrids_IndividualZeroInstances IndependentFragmentGrids_IntegrationTest IndependentFragmentGrids_Sole_NN_Calculation JobMarket_RobustOnKillsSegFaults JobMarket_StableWorkerPool JobMarket_unresolvable_hostname_fix MoreRobust_FragmentAutomation ODR_violation_mpqc_open PartialCharges_OrthogonalSummation PdbParser_setsAtomName PythonUI_with_named_parameters QtGui_reactivate_TimeChanged_changes Recreated_GuiChecks Rewrite_FitPartialCharges RotateToPrincipalAxisSystem_UndoRedo SaturateAtoms_findBestMatching SaturateAtoms_singleDegree StoppableMakroAction Subpackage_CodePatterns Subpackage_JobMarket Subpackage_LinearAlgebra Subpackage_levmar Subpackage_mpqc_open Subpackage_vmg Switchable_LogView ThirdParty_MPQC_rebuilt_buildsystem TrajectoryDependenant_MaxOrder TremoloParser_IncreasedPrecision TremoloParser_MultipleTimesteps TremoloParser_setsAtomName Ubuntu_1604_changes stable
Last change on this file since 321470 was 0773bd, checked in by Frederik Heber <heber@…>, 12 years ago

Added Tcl scripts used for visualizing faulty rolling spheres or the whole surface.

  • in CandidateForTesselation an error message makes explicit reference to animate_sphere, hence we should place it with molecuilder to eas debugging.
  • show_surface can be used to visualize the written TecPlot style .dat file containing the triangle information of the tesselated surface.
  • surfacing produces an animation (i.e. a number of frames) showing the sequence of found triangles and the rolling sphere which can be used to easily produce movies of the on-going tesselation.
  • Property mode set to 100644
File size: 3.9 KB
Line 
1#!/usr/bin/tclsh
2#
3# This scripts displays the rolling sphere used in the tesselation procedure
4# to compute the molecular surface via VMD's graphics interface.
5# It is used during debugging and all its parameters are thrown out by an
6# error message in CandidateForTesselation.cpp.
7
8
9proc animate_sphere { molid atomid1 atomid2 atomid3 rad x1 y1 z1 x2 y2 z2 {step 25} } {
10 global SphereRadius
11 global vector1
12 global vector2
13 global CircleCenter
14 global angle
15 global radius
16 global M_PI
17 set SphereRadius $rad
18
19 # avoid some 'animate dup' bug
20 set molid [molinfo $molid get id]
21 # check molid
22 if {[molinfo $molid get numframes] != 1} {
23 error "Can't find $molid or more than 1 frame."
24 }
25 # step must be integer and greater 2
26 if {$step != int($step)} {
27 error "step must be integer."
28 }
29 if {$step < 2} {
30 error "step should be greater than 2."
31 }
32 # make step-1 copies of current frame
33 for {set i 1} {$i <$step} {incr i} {
34 animate dup frame 0 $molid
35 }
36
37 # select both atoms
38 incr atomid1 -1
39 incr atomid2 -1
40 incr atomid3 -1
41 set selid1 [atomselect $molid "index $atomid1" frame 0]
42 set selid2 [atomselect $molid "index $atomid2" frame 0]
43 set selid3 [atomselect $molid "index $atomid3" frame 0]
44
45 # calculate origin of rotation
46 set Atom1 [$selid1 get {x y z}]
47 puts "Atom1 is $Atom1."
48 set Atom2 [$selid2 get {x y z}]
49 puts "Atom2 is $Atom2."
50 set Atom3 [$selid3 get {x y z}]
51 puts "Atom3 is $Atom3."
52 set CircleCenter [vecadd [vecscale 0.5 [expr $Atom1]] [vecscale 0.5 [expr $Atom2]]]
53 set CircleCenter [vecadd [vecscale 0.5 [expr $Atom1]] [vecscale 0.5 [expr $Atom2]]]
54 puts "CircleCenter is at $CircleCenter."
55
56 # calculate normal
57 set Normaltmp [vecsub [expr $Atom1] [expr $Atom2]]
58 set CirclePlaneNormal [vecnorm $Normaltmp]
59 puts "CirclePlaneNormal is at $CirclePlaneNormal."
60
61 # calculate radius
62 set SphereCenter [vecsub [list $x1 $y1 $z1] $CircleCenter]
63 puts "SphereCenter is at $SphereCenter."
64 set OtherSphereCenter [vecsub [list $x2 $y2 $z2] $CircleCenter]
65 puts "OtherSphereCenter is at $OtherSphereCenter."
66 set radius [veclength $SphereCenter]
67 puts "Radius of circle is $radius."
68 set vector1 [vecnorm $SphereCenter]
69 puts "vector1 is $vector1."
70
71 # calculate other normal vector on plane, pointing out of triangle
72 set vector2 [veccross $CirclePlaneNormal $vector1]
73 set helper [vecsub $CircleCenter [expr $Atom3]]
74 if {[vecdot $helper $vector2] < -1e-10} {
75 puts "vector2 points inwards, rescaling."
76 set vector2 [vecscale -1. $vector2]
77 }
78 puts "vector2 is $vector2."
79
80 # get angle
81 set angle [expr acos([vecdot $SphereCenter $OtherSphereCenter]/[veclength $SphereCenter]/[veclength $OtherSphereCenter])]
82
83 # make angle in right direction (rotating outward in the sense of vector2
84 set SKP [vecdot $OtherSphereCenter $vector2]
85 puts "SKP with SearchDirection is $SKP."
86 if {$SKP < -1e-10} {
87 set angle [expr 2.*$M_PI - $angle]
88 }
89 puts "angle is $angle."
90
91 global vmd_frame
92 trace variable vmd_frame([molinfo top]) w update_current_sphere
93 display update
94 #enumerate_atoms 0
95 return
96}
97
98proc update_current_sphere {name index op} {
99 global SphereRadius
100 global radius
101 global angle
102 global vector1
103 global vector2
104 global CircleCenter
105 # draw sphere
106 set CurrentAngle [expr ($angle/[expr [molinfo $index get numframes]-1])*[molinfo $index get frame]]
107 set center [vecadd [vecscale $radius [vecadd [vecscale [expr cos($CurrentAngle)] $vector1] [vecscale [expr sin($CurrentAngle)] $vector2]]] $CircleCenter]
108 #puts "center is now at $center with CurrentAngle is $CurrentAngle and radius $SphereRadius."
109 draw material Transparent
110 draw color silver
111 if {[draw exists 2] != 0} {
112 draw replace 2
113 }
114 draw sphere $center radius [expr $SphereRadius] resolution 30
115 return
116}
117
118proc animate_sphere_off {} {
119 global vmd_frame
120 trace vdelete vmd_frame([molinfo top]) w update_current_sphere
121 draw delete all
122 animate delete beg 1 end 25 skip 0 [molinfo top]
123 return
124}
125
126#enumerate_atoms 0
127#animate_sphere 0 15 6 3. 4.00145 1.4968 1.28282 1.97354 -2.53854 -1.81601
Note: See TracBrowser for help on using the repository browser.