dara.cif2str module#
Convert CIF to Str format for BGMN.
- check_wyckoff(spacegroup_setting, structure)[source]#
Check if a given spacegroup setting is valid for a structure.
- Parameters:
spacegroup_setting (
dict[str,Any]) – the spacegroup settingstructure (
SymmetrizedStructure) – the symmetrized structure
- Return type:
tuple[list[dict[str,Any]],int]- Returns:
the settings of the elements and the number of errors
- cif2str(cif_path, phase_name_suffix='', working_dir=None, *, lattice_range=0.1, gewicht='0_0', rp=4, k1='0_0^0.01', k2='0_0^0.01', b1='0_0^0.01', lebail=False, custom_params=None, custom_params_map=None)[source]#
Convert CIF to Str format.
- Parameters:
cif_path (
Path) – the path to the CIF filephase_name_suffix (
str) – the suffix of the phase nameworking_dir (
Path|None) – the folder to hold the processed str filelattice_range (
Union[Literal['fixed'],float,int,tuple[float,float],dict[str,Union[Literal['fixed'],float,int,tuple[float,float]]]]) –controls the refinement bounds for the lattice parameters. Can be: - a single float r (default behavior): symmetric range [a - r*a, a + r*a] - the string “fixed”: all lattice parameters are held fixed (not refined) - a tuple (lo, hi): explicit fractional deltas, allowing asymmetric or
- one-sided ranges. For example:
(-0.1, 0.1) is equivalent to 0.1 (symmetric)
(0.0, 0.1) confines refinement to only positive deviations
(-0.1, 0.0) confines refinement to only negative deviations
(-0.05, 0.2) allows asymmetric refinement
a dict mapping a lattice parameter name to any of the above per-parameter specs, for fine-grained per-parameter control. Valid keys are “A”, “B”, “C”, “ALPHA”, “BETA”, “GAMMA” (case-insensitive). Use the wildcard key “*” to set a fallback for any parameter not explicitly listed; if no “*” key is given, unlisted parameters default to a symmetric 0.1. For example:
{“C”: “fixed”, “A”: (-0.05, 0.2), “*”: 0.1} fixes C, refines A asymmetrically, and refines the rest symmetrically at 0.1
{“A”: 0.1, “*”: “fixed”} refines only A and fixes everything else
gewicht (
str) – the weight fraction of the phase to be refined. Options: 0_0, SPHAR0, and SPHAR2. If 0_0, then no preferred orientation. Read more in the BGMN manual.rp (
int) – the peak function to be used in the refinement. Read more in the BGMN manual.k1 (
str) – the first peak parameter to be refined. Read more in the BGMN manual.k2 (
str) – the second peak parameter to be refined. Read more in the BGMN manual.b1 (
str) – the third peak parameter to be refined. Read more in the BGMN manual.lebail (
bool) – whether to use the Le Bail methodcustom_params (
list[str] |None) – optional list of custom BGMN string parameters to inject. This allows for defining complex mathematical equations, global parameters, or fractional occupancies (e.g., [“PARAM=Bglobal=0.05_0.01^0.20 //”, “PARAM=BO=0.1_0.02^0.3 //”]).custom_params_map (
dict[str,dict] |None) – optional dictionary mapping element symbols to dictionaries of parameters to add or overwrite. You can use the wildcard key “*” to apply parameters to all elements that are not specifically matched in the dictionary (e.g., {“*”: {“TDS”: “Bglobal”}, “O”: {“TDS”: “BO”, “Occ”: “OccO”}}).
- Return type:
Path
An example of the output .str file when using custom_params=[“PARAM=Bglobal=0.05_0.01^0.20 //”, “PARAM=BO=0.1_0.02^0.3 //”] and custom_params_map={“*”: {“TDS”: “Bglobal”}, “O”: {“TDS”: “BO”, “Occ”: “OccO”}}:
PHASE=BariumzirconiumtinIVoxide105053 // ICSD_43137 Reference=ICSD_43137 // Formula=Ba1_O3_Sn0.5_Zr0.5 // SpacegroupNo=221 HermannMauguin=P4/m-32/m Setting=1 Lattice=Cubic // PARAM=A=0.416280_0.412117^0.420443 // RP=4 k1=0 k2=0 PARAM=B1=0_0^0.01 GEWICHT=SPHAR4 // GOAL:BariumzirconiumtinIVoxide105053=GEWICHT*ifthenelse(ifdef(d),exp(my*d*3/4),1) // PARAM=Bglobal=0.05_0.01^0.20 // PARAM=BO=0.1_0.02^0.3 // E=BA+2 Wyckoff=b x=0.500000 y=0.500000 z=0.500000 TDS=Bglobal E=(ZR+4(0.5000),SN+4(0.5000)) Wyckoff=a x=0.000000 y=0.000000 z=0.000000 TDS=Bglobal E=O-2 Wyckoff=d x=0.500000 y=0.000000 z=0.000000 TDS=BO Occ=OccO
- get_lattice_parameters_from_lattice(lattice, crystal_system)[source]#
Get lattice parameters from lattice based on the type of lattice. :rtype:
dict[str,float]Note
The lattice parameters are in nm
- get_std_position(spacegroup_setting, wyckoff_letter, positions)[source]#
Get the standard position of a site based on the hall number and wyckoff notation.
- Return type:
tuple[list[float],bool]
- make_lattice_parameters_str(spacegroup_setting, structure, lattice_range)[source]#
Make the lattice parameters string.
- Parameters:
spacegroup_setting (
dict[str,Any]) – the spacegroup setting dict.structure (
SymmetrizedStructure) – the symmetrized structure.lattice_range (
Union[Literal['fixed'],float,int,tuple[float,float],dict[str,Union[Literal['fixed'],float,int,tuple[float,float]]]]) –controls the refinement bounds for lattice parameters. Can be: - “fixed”: all parameters are held fixed (not refined). - float r: symmetric fractional range for all params, i.e. bounds
are [v * (1 - r), v * (1 + r)].
tuple (lo, hi): explicit fractional deltas for all params, bounds are [v * (1 + lo), v * (1 + hi)].
dict mapping parameter name (e.g. “A”, “B”, “C”, “ALPHA”, “BETA”, “GAMMA”, case-insensitive) to any of the above per-parameter specs. Parameters not present in the dict fall back to the value under the “*” key, or to symmetric 0.1 if no “*” key is given.
specs (For tuple)
resulting (if the unmodified value v falls outside the)
window
v (the starting value is clamped to the boundary closest to)
so
hi. (BGMN always receives a valid lo <= start <=)
- Return type:
str
- make_peak_parameter_str(k1, k2, b1, gewicht, rp)[source]#
Make the peak parameter string.
- Return type:
str