Comments (5)
@Armatron44, I've just made a 0.1.18 release that allows MixedSlab
to be used as a backing medium. It will also allow SLD
objects to be constructed with the constraints specified in the previous post:
from refnx.reflect import Slab, SLD
from refnx.analysis import Parameter
deut_par = Parameter(6.36, name="real part of the deuterated SLD")
deut_solvent = SLD(deut_par)
h2o_solvent = SLD(-0.56)
ms_val = 0.6 * deut_par + 0.4 * h2o_solvent.real
mixed_solvent = SLD(ms_val)
from refnx.
One of the reasons that check was introduced is because some Component
need to know what components are before and after them. This would make them unsuitable as backing materials.
A further reason is that the backing slab is also typically the material that is used to solvate the rest of the structure:
If no solvent is specified then the SLD of the solvent is assumed to be the SLD of
Structure[-1].slabs()[-1]
(after any possible slab order reversal).
This means that if Structure.solvent
is not specified then vfsolv
for the backing slab should be 0 and not allowed to vary during a fit (the thickness of the backing slab is also ignored and should be fixed during a fit).
Is there a specific reason why you'd like to have use a MixedSlab as the backing medium? Is it not just easier to construct a Slab
out of a single SLD
object?
from refnx.
The reason I'd like to use a MixedSlab
as the backing component is that I'm trying to model a known volumetric mixture of h- and d-solvent. While the SLD of the h-solvent is known and fixed, the SLD of d-solvent is not known but is expected to be around the SLD at 95–100 % d content. Fortunately, I have a d-contrast so the d-solvent SLD can be determined via a fit. Ideally, I would like to globally fit both contrasts, where the d-solvent SLD is a varying parameter that also determines the SLD of the solvent mixture through a volume fraction function. However, as far as I know, you cannot specify a SLD object in terms of a function of another varying parameter (be that another SLD object or just a standard parameter) without the SLD object adopting a fixed value throughout the fit - is that correct?
As part of my quick check earlier, I did check if a Slab that was solvated by the MixedSlab worked, and it appeared to function well.
from refnx.
What you're asking to do with the MixedSlab seems eminently feasible, I'll look into modifying the code to allow it. You could use the modified code in a Jupyter Notebook, but I don't think I'd change the standalone GUI for this, it would be a bit too fiddly.
I can upgrade your knowledge level, you can apply constraints in refnx to do the kind of thing you were thinking of. Try out the following:
from refnx.reflect import Structure, Slab, SLD
from refnx.analysis import Parameter
# parameter to hold the real part of the deuterated SLD
deut_par = Parameter(6.36, name="real part of the deuterated SLD")
deut_solvent = SLD(deut_par)
print(deut_solvent, deut_solvent.real is deut_par)
# h-solvent
h2o_solvent = SLD(-0.56)
print(h2o_solvent.real)
# I assume that you know what the volume fraction ratios of the two are.
# Here let's say they're 60:40 D/H
ms_val = 0.6 * deut_par + 0.4 * h2o_solvent.real
print(ms_val)
# we should be able to construct an SLD object with ms_val, the changes allowing this are in #530
mixed_solvent = SLD(-1000.0)
mixed_solvent.real = ms_val
print(mixed_solvent)
# test by changing SLD of deut solvent
deut_par.value = 5.0
print(deut_solvent)
print(mixed_solvent)
You could use this mixed_solvent
object as the last slab in constructing a Structure
in a global fit.
from refnx.
from refnx.
Related Issues (20)
- pip install refnx leads to error with missing "_open_mp_helpers" HOT 3
- Drag and drop datasets doesn't work on windows HOT 1
- Save/reload doesn't work for mixed area models HOT 1
- curvefitter.fit does not accept kwargs for ‘L-BFGS-B’ HOT 2
- progress bar for fitting? HOT 6
- Saving and loading models from code HOT 4
- pyopencl does not play well with multiprocessing.
- Spawning of multiple windows when fitting with refnx HOT 1
- Using specified peak_pos (position, FWHM) in ReductionOptions is applied to both reflected and direct beam HOT 2
- Suggestion: add the option to ignore zeros in ReflectDataset? HOT 9
- Frequent Collapse HOT 5
- Inability to reduce older PNR data as the spin channels were not automatically identified HOT 4
- R increase at the beginning of the curve HOT 7
- Minor error in PolarizationEfficiency class matrix HOT 2
- Link equivalent parameters doesn't work for a MixedArea model
- refnx doesn't accept pathlib.Path objects as filenames HOT 2
- search not working on readthedocs HOT 2
- Jax backend HOT 7
- No access to emcee sampler arguements? HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from refnx.