Skip to content

Commit

Permalink
material class abstraction expanded
Browse files Browse the repository at this point in the history
  • Loading branch information
dgursoy committed Aug 16, 2016
1 parent 8ac6f3a commit 533068f
Show file tree
Hide file tree
Showing 2 changed files with 105 additions and 14 deletions.
43 changes: 43 additions & 0 deletions phantom/constants.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# -*- coding: utf-8 -*-
"""
Constants in cgs units.
AVOGADRO_NUMBER : float
Avagadro constant [1/mol]
BOLTZMANN_CONSTANT : float
Boltzmann constant [erg/k]
CLASSICAL_ELECTRON_RADIUS : float
Classical electron radius [cm]
ELECTRONIC_CHARGE : float
Electronic charge [esu]
ELECTRON_VOLT : float
Electron volt (keV) [erg]
ELECTRON_MASS : float
Electron mass [g]
FINE_STRUCTURE_CONSTANT : float
Fine structure constant
PLANCK_CONSTANT : float
Reduced planck's constant [keV*s]
PROTON_MASS : float
Proton mass [g]
SPEED_OF_LIGHT : float
Speed of light in vacuum [cm/s]
THOMPSON_CROSS_SECTION : float
Thomson cross section [cm^2]
PI : float
Ratio of a circle's circumference to its diameter
"""

# Constants in cgs units.
AVOGADRO_NUMBER = 6.02214129e+23
BOLTZMANN_CONSTANT = 1.3806488e-16
CLASSICAL_ELECTRON_RADIUS = 2.8179402894e-13
ELECTRONIC_CHARGE = 4.80320425e-10
ELECTRON_VOLT = 1.602176565e-9
ELECTRON_MASS = 9.10938188e-28
FINE_STRUCTURE_CONSTANT = 7.2973525698e-3
PLANCK_CONSTANT = 6.58211928e-19
PROTON_MASS = 1.67261777e-24
SPEED_OF_LIGHT = 299792458e+2
THOMPSON_CROSS_SECTION = 6.652458734e-25
PI = 3.14159265359
76 changes: 62 additions & 14 deletions phantom/material.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,32 +56,82 @@

logger = logging.getLogger(__name__)

__author__ = "Daniel Ching"
__author__ = "Daniel Ching, Doga Gursoy"
__copyright__ = "Copyright (c) 2016, UChicago Argonne, LLC."
__docformat__ = 'restructuredtext en'
__all__ = ['HyperbolicConcentric',
'DynamicRange', 'UnitCircle', 'Soil', 'Foam']
__all__ = ['Material',
'HyperbolicConcentric',
'DynamicRange',
'UnitCircle',
'Soil',
'Foam']

# Elements and Mixtures - Not Implemented


class Element(Circle):
class Material(Feature):
"""Placeholder for class which uses NIST data to automatically calculate
attenuation values for features based on beam energy.
material properties based on beam energy.
"""

def __init__(self, MeV=1):
def __init__(self, formula, density):
# calculate the value based on the photon energy
super(Element, self).__init__()
super(Material, self).__init__()
self.formula = formula
self.density = density

@property
def compton_cross_section(self, energy):
"""Compton cross-section of the electron [cm^2]."""
raise NotImplementedError

@property
def photoelectric_cross_section(self, energy):
raise NotImplementedError

@property
def atomic_form_factor(self, energy):
"""Measure of the scattering amplitude of a wave by an isolated atom.
Read from NIST database [Unitless]."""
raise NotImplementedError

@property
def atom_concentration(self, energy):
"""Number of atoms per unit volume [1/cm^3]."""
raise NotImplementedError

@property
def reduced_energy_ratio(self, energy):
"""Energy ratio of the incident x-ray and the electron energy [Unitless]."""
raise NotImplementedError

@property
def attenuation():
def photoelectric_absorption(self, energy):
"""X-ray attenuation due to the photoelectric effect [1/cm]."""
raise NotImplementedError

def set_beam_energy():
@property
def compton_scattering(self, energy):
"""X-ray attenuation due to the Compton scattering [1/cm]."""
raise NotImplementedError

# Microstructures
@property
def electron_density(self, energy):
"""Electron density [e/cm^3]."""
raise NotImplementedError

@property
def linear_attenuation(self, energy):
"""Total x-ray attenuation [1/cm]."""
raise NotImplementedError

@property
def refractive_index(self, energy):
raise NotImplementedError

def mass_ratio(self):
raise NotImplementedError

def number_of_elements(self):
raise NotImplementedError


class HyperbolicConcentric(Phantom):
Expand Down Expand Up @@ -204,8 +254,6 @@ def __init__(self):
background = Circle(Point(0.5, 0.5), 0.5, value=1)
self.insert(0, background)

# Microstructures - Not Implemented


class Metal(Phantom):

Expand Down

3 comments on commit 533068f

@carterbox
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dgursoy Why define PI when it's already defined through numpy library?

@dgursoy
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

by mistake

@carterbox
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#14

Please sign in to comment.