Giter VIP home page Giter VIP logo

Comments (5)

andyfaff avatar andyfaff commented on June 12, 2024 1

@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.

andyfaff avatar andyfaff commented on June 12, 2024

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.

Armatron44 avatar Armatron44 commented on June 12, 2024

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.

andyfaff avatar andyfaff commented on June 12, 2024

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.

andyfaff avatar andyfaff commented on June 12, 2024

See also #530 and #531

from refnx.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.