Example #1
0
def set_sample(domain):
    """
        Creating a sample by combining multiple independent domains.
    """
    # Then we create a sample based on the domain
    # Distribution parameters
    N = 102  # number of particules (average)
    # xMin = np.log(4)/np.log(10)
    # xMax = np.log(30) / np.log(10)
    xMin = 4
    xMax = 25
    nx = 5  # number of domain
    # Arithmetic parameters
    mu = 8.29  # mean particule diameter
    sigma = (2.99) ** 2  # 3nm standard deviation

    # LogNormal distribution
    # D = np.logspace(xMin, xMax, nx)
    D = np.linspace(xMin, xMax, nx)
    # D = np.linspace(-np.pi/2, np.pi/2, nx)              # flat distribution
    X, mu_log, sigma_log = StoneX.lognormale(D, mu, sigma)
    # X = np.zeros(D.size) + 1/N

    # Information about the distribution
    text = """Probability distribution : X
    Normale : mu = {}, sigma = {}
    Log-normale : m = {}, s = {}
    Effective Mean diameter: mean(X) = {}
    Number of particules : N = {}
    """.format(
        mu, sigma, mu_log, sigma_log, np.sum(D * X) / np.sum(X), np.sum(X * N)
    )
    StoneX.logger.info(text)

    # Creating the sample
    Density = N * X
    sample = StoneX.create_sample(domain, Density)

    # Change the domains' parameters according to the distribution
    # Domains data
    # diameter (nm), Density, V_f(m**3), V_af(m**3), Surface(m**2), Mag. Moment (A/m)
    domains_data = np.zeros((D.size, 6))
    domains_data[:, 0] = D  # Diameter (nm)
    R = D / 2 * 1e-9  # Radius (m)
    domains_data[:, 1] = Density
    domains_data[:, 2] = 4 / 3 * np.pi * R ** 3  # V_f
    domains_data[:, 3] = 4 / 3 * np.pi * ((domain.t_af + R) ** 3 - R ** 3)  # V_af
    domains_data[:, 4] = 4 * np.pi * R ** 2  # S
    domains_data[:, 5] = sample.domains[0].Ms  # mu_s
    for i, d in enumerate(D):
        StoneX.logger.debug("Diameter {} : {}nm".format(i, np.round(d, 2)))
        sample.domains[i].V_f = domains_data[i, 2]
        sample.domains[i].V_af = domains_data[i, 3]
        sample.domains[i].S = domains_data[i, 4]
        # logger.info(sample.domains[i])

    # Backing up the domain's values
    np.savetxt(
        "{}/domains_data.dat".format(sample.name),
        domains_data,
        header="diameter (nm), Density, V_f(m**3), V_af(m**3), Surface(m**2), Mag. (A/m)",
    )

    return sample
Example #2
0
nx = 20
mu = 2
sigma = 10


# LogNormal distribution
R = np.logspace(xMin, xMax, nx)
X, m, s = StoneX.lognormale(R, mu, sigma)

logger.info("""Distribution de probabilité
        Normale : mu = {}, sigma = {}
        Log-normale : m = {}, s = {}""".format(mu, sigma, m, s))

# Creating the sample
Density = N * X
sample = StoneX.create_sample(domain, Density)

if True:
    pl.plot(R, np.around(X * N), '-ro')
    pl.savefig('{}/distrib.pdf'.format(domain.name), dpi=100)


for i, radius in enumerate(R):
    print(i, radius)
    sample.domains[i].V_f = 4/3 * np.pi * (radius * 1e-9)**3
    sample.domains[i].S = 4 * np.pi * (radius * 1e-9)**2
    sample.domains[i].V_af = 4/3 * np.pi * ( ((radius+d_af) * 1e-9)**3 - (radius * 1e-9)**3   )


################################################################################
# MEASUREMENTS
Example #3
0
    domain.alpha = (2, 'deg')
    domain.S = (200e-9)**2
    domain.V_f = 10e-9 * domain.S
    domain.V_af = 80e-9 * domain.S
    domain.K_f = 400
    domain.K_af = 110
    domain.J_ex = 1e-6

    domain.Ms = 400 * 1e-6 * 1e-3 / (1e-4 * 10 * 1e-9)
    #sample.M_af = 1/1000 * sample.Ms * sample.V_af / sample.V_f

print(domain.V_af)

# Then we create a sample based on the domain
n = 50
sample = StoneX.create_sample(domain, n)

for i, t in enumerate(np.random.normal(50, 20, n)):
    logger.info("N: {}, thickness t = {}nm".format(i, t))
    sample.domains[i].V_af = domain.S * t *1e-9



################################################################################
# MEASUREMENTS
################################################################################
# We can measure the sample or one domain only
vsm.load(sample)
vsm.measure()