Changeset 1230


Ignore:
Timestamp:
Dec 21, 2012 4:23:36 PM (8 years ago)
Author:
toby
Message:

remove .prm conversions, improve space group checking

Location:
branches/sandbox
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/sandbox/addcmds.tcl

    r1189 r1230  
    205205    if {[string trim $spg] == ""} {
    206206        append err "  Space group cannot be blank\n"
     207    }
     208    # check if standard and add spaces, as needed
     209    if {[set nspg [CheckSpg $spg]] != ""} {
     210        set spg $nspg
     211        $np.t2 delete 0 end
     212        $np.t2 insert end $nspg
    207213    }
    208214    foreach i {a b c} {
     
    527533}
    528534
    529 # convert a file to Win-95 direct access
     535# convert a file to Win-95 direct access -- this is not used anymore
    530536proc WinCvt {file win} {
    531537    global expgui
     
    764770    fconfigure $in -translation lf
    765771    while {[set len [gets $in line]] >= 0} {
    766         if {$len != 81 || [string range $line end end] != "\r"} {
    767             set ans [MyMessageBox -parent $np -title "Convert?" \
    768                     -message "File $inp is not in the correct format for GSAS.\nOK to convert?" \
    769                     -icon warning -type {OK Quit} -default OK]
    770             if {$ans == "ok"} {
     772        #if {$len != 81 || [string range $line end end] != "\r"} {
     773        #    set ans [MyMessageBox -parent $np -title "Convert?" \
     774        #           -message "File $inp is not in the correct format for GSAS.\nOK to convert?" \
     775        #           -icon warning -type {OK Quit} -default OK]
     776        #    if {$ans == "ok"} {
    771777                # convert and reopen the file
    772                 close $in
    773                 WinCvt $inp $np
    774                 set in [open $inp r]
    775                 fconfigure $in -translation lf
    776                 set line {}
    777             } else {
    778                 return
    779             }
    780         }
     778        #       close $in
     779        #       WinCvt $inp $np
     780        #       set in [open $inp r]
     781        #       fconfigure $in -translation lf
     782        #       set line {}
     783        #    } else {
     784        #       return
     785        #    }
     786        #}
    781787        # scan for the INS   BANK line
    782788        if {[string first "INS   BANK" $line] == 0} {
     
    22032209        $np.t1 insert end "from $file"
    22042210    }
     2211    set spg [lindex $input 0]
     2212    set expgui(coordList) [lindex $input 2]
     2213    set msg [lindex $input 3]
     2214
    22052215    $np.t2 delete 0 end
    2206     $np.t2 insert end [lindex $input 0]
     2216    if {$spg == ""} {
     2217        set msg "Warning: a Space Group must be specified."
     2218    } elseif {[set nspg [CheckSpg $spg]] == ""} {
     2219        $np.t2 insert end $spg
     2220        if {$msg != ""} {append msg " "}
     2221        append msg "Warning: this space group is not a standard setting. It may be correct, but check it carefully."
     2222    } else {
     2223        $np.t2 insert end $nspg
     2224    }
    22072225    foreach i {.e1a .e1b .e1c .e2a .e2b .e2g} val [lindex $input 1] {
    22082226        $np.f$i delete 0 end
    22092227        $np.f$i insert end $val
    22102228    }
    2211     set expgui(coordList) [lindex $input 2]
    2212     set msg [lindex $input 3]
    22132229    if {$msg != ""} {
    22142230        catch {destroy $np.msg}
    2215         grid [label $np.msg -text $msg -fg red -anchor center -bd 4 -relief raised] \
     2231        grid [label $np.msg -text $msg -fg red -anchor center -bd 4 -relief raised -wraplength 60] \
    22162232                -column 0 -columnspan 99 -row 20 -sticky ew
    22172233    }
     
    26242640    if {$shift != ""} {
    26252641        append warn "Note that this space group ($spg) has both Origin 1 and Origin 2 settings. Origin 2 must be used in GSAS. Please check atom multiplicities (or use the Results/composition command) to verify you have the correct origin setting. Note that the Xform Atoms/Xform Origin 1 to Origin 2 button can be used to correct this.\n"
     2642    } elseif {[CheckSpg $spg] == ""} {
     2643        append warn "Note that this space group is not a standard setting. It still may be correct as input or may have a typographic error. Please confirm that the computed density is in the expected range and that atoms have the correct site multiplicities."
    26262644    }
    26272645    if {$warn != ""} {
     
    28162834    }
    28172835}
     2836# space group table
     2837set spglist {
     2838    "P 1" "P -1"
     2839
     2840    "P 2" "P 21" "P m" "P a" "P c" "P n" "P 2/m" "P 21/m"
     2841    "P 2/c" "P 2/a" "P 2/n" "P 21/c" "P 21/a" "P 21/n"
     2842
     2843    "C 2" "C m" "C c" "C n" "C 2/m" "C 2/c" "C 2/n"
     2844
     2845    "P 2 2 2" "P 2 2 21" "P 2 21 2" "P 21 2 2" "P 21 21 2" "P 21 2 21"
     2846    "P 2 21 21" "P 21 21 21" "P m m 2" "P m 2 m" "P 2 m m" "P m c 21"
     2847    "P c m 21" "P 21 m a" "P 21 a m" "P b 21 m" "P m 21 b" "P c c 2"
     2848    "P 2 a a" "P b 2 b" "P m a 2" "P b m 2" "P 2 m b" "P 2 c m"
     2849    "P c 2 m" "P m 2 a" "P c a 21" "P b c 21" "P 21 a b" "P 21 c a"
     2850    "P c 21 b" "P b 21 a" "P n c 2" "P c n 2" "P 2 n a" "P 2 a n"
     2851    "P b 2 n" "P n 2 b" "P m n 21" "P n m 21" "P 21 m n" "P 21 n m"
     2852    "P n 21 m" "P m 21 n" "P b a 2" "P 2 c b" "P c 2 a" "P n a 21"
     2853    "P b n 21" "P 21 n b" "P 21 c n" "P c 21 n" "P n 21 a"
     2854    "P n n 2" "P 2 n n" "P n 2 n" "P m m m" "P n n n" "P c c m"
     2855    "P m a a" "P b m b" "P b a n" "P n c b" "P c n a"
     2856    "P m m a" "P m m b" "P b m m" "P c m m" "P m c m" "P m a m"
     2857    "P n n a" "P n n b" "P b n n" "P c n n" "P n c n" "P n a n"
     2858    "P m n a" "P n m b" "P b m n" "P c n m" "P n c m" "P m a n"
     2859    "P c c a" "P c c b" "P b a a" "P c a a" "P b c b" "P b a b"
     2860    "P b a m" "P m c b" "P c m a" "P c c n" "P n a a" "P b n b"
     2861    "P b c m" "P c a m" "P m c a" "P m a b" "P b m a" "P c m b"
     2862    "P n n m" "P m n n" "P n m n" "P m m n" "P n m m" "P m n m"
     2863    "P b c n" "P c a n" "P n c a" "P n a b" "P b n a" "P c n b"
     2864    "P b c a" "P c a b" "P n m a" "P m n b" "P b n m" "P c m n"
     2865    "P m c n" "P n a m"
     2866
     2867    "C 2 2 21" "C 2 2 2" "C m m 2" "C m c 21" "C c c 2" "C m 2 m" "C 2 m m"
     2868    "C m 2 a" "C 2 m b" "C 2 c m" "C c 2 m" "C 2 c m" "C c 2 m"
     2869    "C m c a" "C m m m" "C c c m" "C m m a" "C c c a" "C m c m"
     2870
     2871    "I 2 2 2" "I 21 21 21" "I m m m" "I m m 2" "I m 2 m" "I 2 m m"
     2872    "I b a 2" "I 2 c b" "I c 2 a" "I m a 2" "I b m 2" "I 2 m b"
     2873    "I 2 c m" "I c 2 m" "I m 2 a" "I b a m" "I m c b" "I c m a"
     2874    "I b c a" "I c a b" "I m m a" "I m m b" "I b m m " "I c m m"
     2875    "I m c m" "I m a m"
     2876   
     2877    "F 2 2 2" "F m m m"  "F d d d" "F m m 2" "F m 2 m" "F 2 m m"
     2878    "F d d 2" "F d 2 d" "F 2 d d"
     2879
     2880    "P 4" "P 41" "P 42" "P 43" "P -4" "P 4/m" "P 42/m" "P 4/n" "P 42/n"
     2881    "P 4 2 2" "P 4 21 2" "P 41 2 2" "P 41 21 2" "P 42 2 2"
     2882    "P 42 21 2" "P 43 2 2" "P 43 21 2" "P 4 m m" "P 4 b m" "P 42 c m"
     2883    "P 42 n m" "P 4 c c" "P 4 n c" "P 42 m c" "P 42 b c" "P -4 2 m"
     2884    "P -4 2 c" "P -4 21 m" "P -4 21 c" "P -4 m 2" "P -4 c 2" "P -4 b 2"
     2885    "P -4 n 2" "P 4/m m m" "P 4/m c c" "P 4/n b m" "P 4/n n c" "P 4/m b m"
     2886    "P 4/m n c" "P 4/n m m" "P 4/n c c" "P 42/m m c" "P 42/m c m"
     2887    "P 42/n b c" "P 42/n n m" "P 42/m b c" "P 42/m n m" "P 42/n m c"
     2888    "P 42/n c m"
     2889
     2890    "I 4" "I 41" "I -4" "I 4/m" "I 41/a" "I 4 2 2" "I 41 2 2" "I 4 m m"
     2891    "I 4 c m" "I 41 m d" "I 41 c d"
     2892    "I -4 m 2" "I -4 c 2" "I -4 2 m" "I -4 2 d" "I 4/m m m" "I 4/m c m"
     2893    "I 41/a m d" "I 41/a c d"
     2894
     2895    "R 3" "R -3" "R 3 2" "R 3 m" "R 3 c" "R -3 m" "R -3 c"
     2896   
     2897    "P 3" "P 31" "P 32" "P -3" "P 3 1 2" "P 3 2 1" "P 31 1 2"
     2898    "P 31 2 1" "P 32 1 2" "P 32 2 1"  "P 3 m 1" "P 3 1 m" "P 3 c 1"
     2899    "P 3 1 c" "P -3 1 m" "P -3 1 c" "P -3 m 1" "P -3 c 1" "P 6" "P 61"
     2900    "P 65" "P 62" "P 64" "P 63" "P -6" "P 6/m" "P 63/m" "P 6 2 2"
     2901    "P 61 2 2" "P 65 2 2" "P 62 2 2" "P 64 2 2" "P 63 2 2" "P 6 m m"
     2902    "P 6 c c" "P 63 c m" "P 63 m c" "P -6 m 2" "P -6 c 2" "P -6 2 m"
     2903    "P -6 2 c" "P 6/m m m" "P 6/m c c" "P 63/m c m" "P 63/m m c"
     2904
     2905    "P 2 3" "P 21 3" "P m 3" "P n 3" "P a 3" "P 4 3 2" "P 42 3 2"
     2906    "P 43 3 2" "P 41 3 2" "P -4 3 m" "P -4 3 n" "P m 3 m" "P n 3 n"
     2907    "P m 3 n" "P n 3 m"
     2908
     2909    "I 2 3" "I 21 3" "I m -3" "I a -3"  "I 4 3 2" "I 41 3 2"
     2910    "I -4 3 m"  "I -4 3 d" "I m -3 m" "I a -3 d"
     2911
     2912    "F 2 3" "F m -3" "F d -3" "F 4 3 2" "F 41 3 2" "F -4 3 m"
     2913    "F -4 3 c" "F m -3 m" "F m -3 c" "F d -3 m" "F d -3 c"
     2914}
     2915
     2916# check a space group ignoring spaces to see if it matches a
     2917# standard one, if so adjust spaces.
     2918# retain final "R" for rhombodedral settings, but remove the optional "H"
     2919proc CheckSpg {spg} {
     2920    set spg [string trim $spg]
     2921    set lastchar [string toupper [string range $spg end end]]
     2922    if {$lastchar == "R"} {
     2923        # truncate cell setting code
     2924        set spg [string range $spg 0 end-1]
     2925    } elseif {$lastchar == "H"} {
     2926        set spg [string range $spg 0 end-1]
     2927        set lastchar ""
     2928    } else {
     2929        set lastchar ""
     2930    }
     2931    regsub -all { } [string tolower $spg] {} spg
     2932    foreach s $::spglist {
     2933        if {$spg == [regsub -all { } [string tolower $s] {}]} {
     2934            if {$lastchar == ""} {return $s}
     2935            return "$s $lastchar"
     2936        }
     2937    }
     2938    return
     2939}
    28182940
    28192941# default values
  • branches/sandbox/import_cif.tcl

    r1228 r1230  
    9595    catch {
    9696        set spg [ValueFromCIF block${i} _symmetry_space_group_name_h-m]
    97         set sgtmp [string toupper $spg]
    98         # remove spaces from space group
    99         regsub -all " " $sgtmp "" sgtmp
    100         # check for final H
    101         if {[string range $sgtmp end end] == "H"} {
    102             set sgtmp [string range $sgtmp 0 end-1]
    103         }
    104         # make a copy where we treat bar 3 as the same as 3
    105         regsub -- "-3" $sgtmp "3" sgtmp3
    106         # see if this space group exists in the table
    107         set fp1 [open [file join \
    108                 $expgui(scriptdir) spacegrp.ref] r]
    109         while {[gets $fp1 line] >= 0} {
    110             set testsg [string toupper [lindex $line 8]]
    111             regsub -all " " $testsg "" testsg
    112             if {$testsg == $sgtmp} {
    113                 set spg [lindex $line 8]
    114                 set sgnum [lindex $line 1]
    115                 break
    116             } elseif {[lindex $line 1] >= 200} {
    117                 regsub -- "-3" $testsg "3" testsg3
    118                 if {$testsg3 == $sgtmp3} {
    119                     set spg [lindex $line 8]
    120                     set sgnum [lindex $line 1]
    121                     break
    122                 }
    123             } elseif {[lindex $line 1] <= 18} {
    124                 # monoclinic: change operators of form "1 xxx 1" to "xxx"
    125                 regsub -- " 1 (.*) 1" [string toupper [lindex $line 8]] "\\1" testsg
    126                 # remove spaces from space group
    127                 regsub -all " " $testsg "" testsg
    128                 if {$testsg == $sgtmp} {
    129                     set spg [lindex $line 8]
    130                     set sgnum [lindex $line 1]
    131                     break
    132                 }
    133             }
    134         }
    135         close $fp1
    136         if {$spg == ""} {
    137             set msg "Warning: a Space Group must be specified"
    138         } elseif {$sgnum == ""} {
    139             set msg "Warning: the Space Group ($spg) is non-standard. Please confirm that this is what you intend!"
    140         }
    14197    }
    14298    set cell {}
Note: See TracChangeset for help on using the changeset viewer.