Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add example to show how to create a custom Exposition class #37

Open
RemDelaporteMathurin opened this issue Jun 11, 2021 · 0 comments
Open
Labels
documentation Improvements or additions to documentation good first issue Good for newcomers

Comments

@RemDelaporteMathurin
Copy link
Collaborator

Users might be interested in creating custom classes to process files.

For instance, add a non-instantaneous recombination coefficient to compute the surface concentration more accurately.

This is an example.

What do you think @ehodille?

import numpy as np

import divHretention


class ExpositionWithRecombination(divHretention.Exposition):
    def __init__(self, filename, filetype):
        super().__init__(filename, filetype)

    def compute_surface_concentration(self):
        super().compute_surface_concentration()

        k_B = 8.6e-5
        K_0_W = 1e-12
        E_K_W = 0.8
        K = K_0_W*np.exp(-E_K_W/k_B/self.temperature)
        self.concentration += (self.ion_flux/K)**0.5
        self.concentration += (self.atom_flux/K)**0.5


filename = "data/exposure_conditions_divertor/WEST/West-LSN-P1.6e+21-IP0.449MW.csv"

my_recomb_exp = ExpositionWithRecombination(filename, "WEST")
my_exp = divHretention.Exposition(filename, "WEST")


import matplotlib.pyplot as plt

plt.plot(my_recomb_exp.arc_length, my_recomb_exp.inventory)
plt.plot(my_exp.arc_length, my_exp.inventory)
plt.annotate(
    "Non-instantaneous \n recombination",
    (my_recomb_exp.arc_length[-1], my_recomb_exp.inventory[-1]))
plt.annotate(
    "Instantaneous",
    (my_exp.arc_length[-1], my_exp.inventory[-1]))
plt.yscale("log")
plt.xlim(right=0.8)
plt.xlabel("Arc length (m)")
plt.ylabel("Inventory (H/m)")
plt.show()

image

@RemDelaporteMathurin RemDelaporteMathurin added the documentation Improvements or additions to documentation label Jun 11, 2021
@RemDelaporteMathurin RemDelaporteMathurin added the good first issue Good for newcomers label Jun 21, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

1 participant