Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions hexrd/powder/wppf/WPPF.py
Original file line number Diff line number Diff line change
Expand Up @@ -1869,21 +1869,21 @@ def _set_phase_params_vals_to_class(
if atominfo_vary:
updated_atominfo = True

texture_model = self.texture_model.get(p)
pname = f"{p}_p_md"
if pname in params and hasattr(texture_model, 'P_MD'):
val = params[pname].value
# computespectrum() reads P_MD from self.params
self.params[pname].value = val
if texture_model.P_MD != val:
texture_model.P_MD = val

if updated_lp:
self.calctth()

if updated_lp or updated_atominfo:
self.calcsf()

"""
In case March-Dollase texture parameters were used, we can
update those here
"""
name = f"{pre}p_md"
if name in params:
val = params[name].value
self.texture_model[p].P_MD = val

self.phases.phase_fraction = pf / np.sum(pf)

def on_smoothing_modified(self):
Expand Down
2 changes: 1 addition & 1 deletion hexrd/powder/wppf/texture.py
Original file line number Diff line number Diff line change
Expand Up @@ -740,7 +740,7 @@ def get_parameters(

pname = f'{self.material.name}_p_md'

params.add(pname, value=1.0, vary=False)
params.add(pname, value=self.P_MD, min=1e-3, vary=vary)

return params

Expand Down
7 changes: 4 additions & 3 deletions tests/powder/wppf/test_wppf_texture.py
Original file line number Diff line number Diff line change
Expand Up @@ -287,8 +287,9 @@ def test_wppf_march_dollase_texture(texture_instrument, texture_img_dict):

R.Refine()

# P_MD refinement should not make Rwp worse
assert R.Rwp <= rwp_before_pmd + 1e-4
# P_MD should refine away from random and improve the fit
assert not np.isclose(R.params['Ni_p_md'].value, 1.0)
assert R.Rwp < rwp_before_pmd - 0.01

# Test texture_index (polymorphic interface)
ti = R.texture_index
Expand Down Expand Up @@ -359,7 +360,7 @@ def test_march_dollase_texture_factors(texture_instrument, texture_img_dict):
'eta_step': 5,
}
R = Rietveld(**kwargs)
R.params['Ni_p_md'].value = 1.5
assert R.params['Ni_p_md'].value == 1.5 # taken from P_MD

# calc_pf_rings should produce constant rings matching texture_factors
md.calc_pf_rings(R.params)
Expand Down
Loading