@@ -4493,7 +4493,7 @@ def LoadUnitCell(event):
4493
4493
4494
4494
# TODO: I think this used to work, but this needs to be revisited due to
4495
4495
# AttributeError: 'G2DataWindow' object has no attribute 'ReImportMenuId'
4496
- # from:
4496
+ # from:
4497
4497
# reqrdr = G2frame.dataWindow.ReImportMenuId.get(event.GetId())
4498
4498
#
4499
4499
# def ImportUnitCell(event):
@@ -5163,15 +5163,15 @@ def _showWebPage(event):
5163
5163
txt = event .GetEventObject ().page
5164
5164
tmp = tempfile .NamedTemporaryFile (suffix = '.html' ,delete = False )
5165
5165
with open (tmp .name ,'w' ) as fp :
5166
- fp .write (txt .replace ('<HEAD>' ,'<head><base href="https://stokes.byu.edu/iso/ ">' ,))
5166
+ fp .write (txt .replace ('<HEAD>' ,'<head><base href="https://stokes.byu.edu/">' ,))
5167
5167
fileList .append (tmp .name )
5168
5168
G2G .ShowWebPage ('file://' + tmp .name ,G2frame )
5169
5169
5170
5170
def showWebtext (txt ):
5171
5171
import tempfile
5172
5172
tmp = tempfile .NamedTemporaryFile (suffix = '.html' ,delete = False )
5173
5173
with open (tmp .name ,'w' ) as fp :
5174
- fp .write (txt .replace ('<HEAD>' ,'<head><base href="https://stokes.byu.edu/iso/ ">' ,))
5174
+ fp .write (txt .replace ('<HEAD>' ,'<head><base href="https://stokes.byu.edu/">' ,))
5175
5175
fileList .append (tmp .name )
5176
5176
G2G .ShowWebPage ('file://' + tmp .name ,G2frame )
5177
5177
@@ -5180,82 +5180,131 @@ def _get_opt_val(opt_name, out):
5180
5180
opt_match = re .search (opt_pattern , out )
5181
5181
5182
5182
return opt_match .group (1 )
5183
-
5184
- def setup_kvec_input (k_vec ):
5183
+
5184
+ def grab_all_kvecs (out_html ):
5185
+ """Extract all k-vectors from the ISODISTORT output HTML."""
5186
+ from fractions import Fraction
5187
+ import re
5188
+
5189
+ kvec1_pattern = r'<SELECT NAME="kvec1">(.*?)</SELECT>'
5190
+ kvec1_match = re .search (kvec1_pattern , out_html , re .DOTALL )
5191
+
5192
+ if kvec1_match :
5193
+ select_content = kvec1_match .group (1 )
5194
+
5195
+ # Extract option values
5196
+ option_pattern = r'<OPTION VALUE="([^"]*)"[^>]*>([^<]*)</OPTION>'
5197
+ options = re .findall (option_pattern , select_content )
5198
+
5199
+ final_kvec_keys = []
5200
+ for value , _ in options :
5201
+ final_kvec_keys .append (value )
5202
+
5203
+ all_kvecs = {}
5204
+ for key in final_kvec_keys :
5205
+ pattern_str = key .split ("(" )[1 ].split (")" )[0 ]
5206
+ a_val = pattern_str .split ("," )[0 ]
5207
+ b_val = pattern_str .split ("," )[1 ]
5208
+ c_val = pattern_str .split ("," )[2 ]
5209
+ if a_val == "1/2" :
5210
+ a_val = Fraction (1 , 2 )
5211
+ elif a_val == "1/3" :
5212
+ a_val = Fraction (1 , 3 )
5213
+ elif a_val == "1" :
5214
+ a_val = 1
5215
+ elif a_val == "0" :
5216
+ a_val = 0
5217
+
5218
+ if b_val == "1/2" :
5219
+ b_val = Fraction (1 , 2 )
5220
+ elif b_val == "1/3" :
5221
+ b_val = Fraction (1 , 3 )
5222
+ elif b_val == "1" :
5223
+ b_val = 1
5224
+ elif b_val == "0" :
5225
+ b_val = 0
5226
+
5227
+ if c_val == "1/2" :
5228
+ c_val = Fraction (1 , 2 )
5229
+ elif c_val == "1/3" :
5230
+ c_val = Fraction (1 , 3 )
5231
+ elif c_val == "1" :
5232
+ c_val = 1
5233
+ elif c_val == "0" :
5234
+ c_val = 0
5235
+
5236
+ all_kvecs [key ] = (a_val , b_val , c_val )
5237
+
5238
+ return all_kvecs
5239
+ else :
5240
+ return None
5241
+
5242
+ def setup_kvec_input (k_vec , k_vec_dict , symmetry = None ):
5185
5243
"""Set up the input for isodistort post request
5186
5244
5187
5245
Args:
5188
5246
k_vec (str): The k-vector to use for the isodistort request.
5247
+ k_vec_dict (dict): The dictionary containing the k-vector
5248
+ form extracted from isodistort.
5249
+ symmetry (str, optional): The crystal system.
5189
5250
5190
5251
Returns:
5191
5252
dict: New entries and those need to be corrected in the data
5192
5253
to be used in the post request.
5193
5254
"""
5194
- from fractions import Fraction
5195
-
5196
- k_vec_dict = {
5197
- " 1 *GM, k16 (0,0,0)" : (0 , 0 , 0 ),
5198
- " 2 *DT, k11 (0,0,g)" : (0 , 0 , "a" ),
5199
- " 3 *LD, k6 (a,a,0)" : ("a" , "a" , 0 ),
5200
- " 4 *SM, k5 (a,0,0)" : ("a" , 0 , 0 ),
5201
- " 5 *A, k17 (0,0,1/2)" : (0 , 0 , Fraction (1 , 2 )),
5202
- " 6 *H, k15 (1/3,1/3,1/2)" : (
5203
- Fraction (1 , 3 ),
5204
- Fraction (1 , 3 ),
5205
- Fraction (1 , 2 )
5206
- ),
5207
- " 7 *K, k13 (1/3,1/3,0)" : (Fraction (1 , 3 ), Fraction (1 , 3 ), 0 ),
5208
- " 8 *L, k14 (1/2,0,1/2)" : (Fraction (1 , 2 ), 0 , Fraction (1 , 2 )),
5209
- " 9 *M, k12 (1/2,0,0)" : (Fraction (1 , 2 ), 0 , 0 ),
5210
- "10 *P, k10 (1/3,1/3,g)" : (
5211
- Fraction (1 , 3 ),
5212
- Fraction (1 , 3 ),
5213
- "g"
5214
- ),
5215
- "11 *Q, k8 (a,a,1/2)" : ("a" , "a" , Fraction (1 , 2 )),
5216
- "12 *R, k7 (a,0,1/2)" : ("a" , 0 , Fraction (1 , 2 )),
5217
- "13 *U, k9 (1/2,0,g)" : (Fraction (1 , 2 ), 0 , "g" ),
5218
- "14 *B, k1 (a,b,0)" : ("a" , "b" , 0 ),
5219
- "15 *C, k4 (a,a,g)" : ("a" , "a" , "g" ),
5220
- "16 *D, k3 (a,0,g)" : ("a" , 0 , "g" ),
5221
- "17 *E, k2 (a,b,1/2)" : ("a" , "b" , Fraction (1 , 2 )),
5222
- "18 *GP, k0 (a,b,g)" : ("a" , "b" , "g" )
5223
- }
5224
-
5225
- def match_vector_pattern (k_vec , k_vec_dict ):
5255
+ def match_vector_pattern (k_vec , k_vec_dict , symmetry = None ):
5226
5256
"""Check the k-vector against the standard form in isodistort.
5227
5257
5228
5258
Args:
5229
- k_vec (str): The k-vector to use for the isodistort
5230
- request.
5231
- k_vec_dict (dict): The standard k-vector form in
5232
- isodistort.
5259
+ k_vec (str): The k-vector to use for the isodistort request.
5260
+ k_vec_dict (dict): The standard k-vector form in isodistort.
5261
+ symmetry (str, optional): The crystal system.
5233
5262
5234
5263
Returns:
5235
5264
str: The standard k-vector form in isodistort.
5236
5265
"""
5266
+ from itertools import permutations
5267
+
5237
5268
all_matches = list ()
5269
+
5238
5270
for desc , pattern in k_vec_dict .items ():
5239
5271
if len (pattern ) != len (k_vec ):
5240
5272
continue
5241
- placeholders = {}
5242
- match = True
5243
- for p_val , k_val in zip (pattern , k_vec ):
5244
- if isinstance (p_val , str ):
5245
- if p_val .isalpha ():
5246
- if p_val not in placeholders :
5247
- placeholders [p_val ] = k_val
5248
- elif placeholders [p_val ] != k_val :
5273
+
5274
+ # Generate sequences to check based on symmetry
5275
+ if symmetry == 'cubic' :
5276
+ # For cubic symmetry, check all permutations of k_vec
5277
+ k_vec_sequences = list (permutations (k_vec ))
5278
+ else :
5279
+ # For other symmetries, maintain original order
5280
+ k_vec_sequences = [k_vec ]
5281
+
5282
+ # Check if any permutation matches the pattern
5283
+ pattern_matched = False
5284
+ for k_vec_seq in k_vec_sequences :
5285
+ placeholders = {}
5286
+ match = True
5287
+ for p_val , k_val in zip (pattern , k_vec_seq ):
5288
+ if isinstance (p_val , str ):
5289
+ if p_val .isalpha ():
5290
+ if p_val not in placeholders :
5291
+ placeholders [p_val ] = k_val
5292
+ elif placeholders [p_val ] != k_val :
5293
+ match = False
5294
+ break
5295
+ else :
5249
5296
match = False
5250
5297
break
5251
5298
else :
5252
- match = False
5253
- break
5254
- else :
5255
- if p_val != k_val :
5256
- match = False
5257
- break
5258
- if match :
5299
+ if p_val != k_val :
5300
+ match = False
5301
+ break
5302
+
5303
+ if match :
5304
+ pattern_matched = True
5305
+ break
5306
+
5307
+ if pattern_matched :
5259
5308
all_matches .append (desc )
5260
5309
5261
5310
idp_params_num = 3
@@ -5271,7 +5320,7 @@ def match_vector_pattern(k_vec, k_vec_dict):
5271
5320
5272
5321
return final_match
5273
5322
5274
- k_vec_form = match_vector_pattern (k_vec , k_vec_dict )
5323
+ k_vec_form = match_vector_pattern (k_vec , k_vec_dict , symmetry = "cubic" )
5275
5324
5276
5325
data_update = dict ()
5277
5326
data_update ['kvec1' ] = k_vec_form
@@ -5298,7 +5347,7 @@ def match_vector_pattern(k_vec, k_vec_dict):
5298
5347
from fractions import Fraction
5299
5348
from GSASII .exports import G2export_CIF
5300
5349
from . import ISODISTORT as ISO
5301
- isoformsite = 'https://iso.byu.edu/iso/ isodistortform.php'
5350
+ isoformsite = 'https://iso.byu.edu/isodistortform.php'
5302
5351
5303
5352
if not G2frame .kvecSearch ['mode' ]:
5304
5353
return
@@ -5313,7 +5362,7 @@ def match_vector_pattern(k_vec, k_vec_dict):
5313
5362
5314
5363
if kpoint is None :
5315
5364
wx .MessageBox (
5316
- "Please select a k-vector from the table." ,
5365
+ "Please select a k-vector from the table." ,
5317
5366
style = wx .ICON_INFORMATION ,
5318
5367
caption = 'Isotropic Subgroup Generation'
5319
5368
)
@@ -5329,7 +5378,7 @@ def match_vector_pattern(k_vec, k_vec_dict):
5329
5378
This can take up to a few minutes. Check the terminal for progress.
5330
5379
'''
5331
5380
wx .MessageBox (
5332
- f"{ isoCite } \n \n { info_str } " ,
5381
+ f"{ isoCite } \n \n { info_str } " ,
5333
5382
style = wx .ICON_INFORMATION ,
5334
5383
caption = 'Isotropic Subgroup Generation'
5335
5384
)
@@ -5438,7 +5487,9 @@ def match_vector_pattern(k_vec, k_vec_dict):
5438
5487
data ['input' ] = 'kvector'
5439
5488
data ['irrepcount' ] = '1'
5440
5489
5441
- data_update = setup_kvec_input (kpoint_frac )
5490
+ kvec_dict = grab_all_kvecs (out2 )
5491
+
5492
+ data_update = setup_kvec_input (kpoint_frac , kvec_dict )
5442
5493
for key , value in data_update .items ():
5443
5494
data [key ] = value
5444
5495
@@ -5552,7 +5603,7 @@ def match_vector_pattern(k_vec, k_vec_dict):
5552
5603
# reopen tree to the original phase
5553
5604
def _ShowPhase ():
5554
5605
phId = G2gd .GetGPXtreeItemId (G2frame , G2frame .root , 'Phases' )
5555
- G2frame .GPXtree .Expand (phId )
5606
+ G2frame .GPXtree .Expand (phId )
5556
5607
phId = G2gd .GetGPXtreeItemId (G2frame , phId , phsnam )
5557
5608
G2frame .GPXtree .SelectItem (phId )
5558
5609
@@ -5563,7 +5614,7 @@ def _ShowPhase():
5563
5614
{ os .getcwd ()}
5564
5615
'''
5565
5616
wx .MessageBox (
5566
- info_msg ,
5617
+ info_msg ,
5567
5618
style = wx .ICON_INFORMATION ,
5568
5619
caption = 'Isotropic Subgroup Generation'
5569
5620
)
@@ -7470,7 +7521,7 @@ def setBackgroundColors(im,it):
7470
7521
def OnToggleExt (event ):
7471
7522
G2frame .Hide = not G2frame .Hide
7472
7523
UpdateReflectionGrid (G2frame ,data ,HKLF = True ,Name = Name )
7473
-
7524
+
7474
7525
def OnPageChanged (event ):
7475
7526
'''Respond to a press on a phase tab by displaying the reflections. This
7476
7527
routine is needed because the reflection table may not have been created yet.
0 commit comments