Skip to content

Commit 3f01152

Browse files
committed
Planar and isotropic surface binding models added.
1 parent 4b9b050 commit 3f01152

11 files changed

+70
-40
lines changed

examples/boron_nitride.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ Ec = [ 0.5, 0.5,]
2727
Z = [ 5, 7,]
2828
m = [ 10.811, 14,]
2929
interaction_index = [0, 0]
30-
surface_binding_model = "AVERAGE"
30+
surface_binding_model = {"PLANAR"={calculation="TARGET"}}
3131
bulk_binding_model = "AVERAGE"
3232

3333
[particle_parameters]

examples/boron_nitride_0D.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ Ec = [ 1.0, 1.0,]
2727
Z = [ 5, 7,]
2828
m = [ 10.811, 14,]
2929
interaction_index = [0, 0]
30-
surface_binding_model = "AVERAGE"
30+
surface_binding_model = {"PLANAR"={calculation="TARGET"}}
3131
bulk_binding_model = "AVERAGE"
3232

3333
[particle_parameters]

examples/boron_nitride_sphere.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ Ec = [ 5.76, 1.0,]
2727
Z = [ 5, 7,]
2828
m = [ 10.811, 14,]
2929
interaction_index = [0, 0]
30-
surface_binding_model = "AVERAGE"
30+
surface_binding_model = {"ISOTROPIC"={calculation="TARGET"}}
3131
bulk_binding_model = "AVERAGE"
3232

3333
[particle_parameters]

examples/layered_geometry.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,5 +66,5 @@ Ec = [ 3.5, 2.0, 3.0, 1.5,]
6666
Z = [ 22, 8, 13, 14,]
6767
m = [ 47.867, 15.9994, 26.98, 28.08553,]
6868
interaction_index = [0, 0, 0, 0]
69-
surface_binding_model = "TARGET"
69+
surface_binding_model = {"PLANAR"={calculation="TARGET"}}
7070
bulk_binding_model = "AVERAGE"

examples/layered_geometry_1D.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,5 +63,5 @@ Ec = [ 3.5, 2.0, 3.0, 1.5,]
6363
Z = [ 22, 8, 13, 14,]
6464
m = [ 47.867, 15.9994, 26.98, 28.08553,]
6565
interaction_index = [0, 0, 0, 0]
66-
surface_binding_model = "TARGET"
66+
surface_binding_model = {"PLANAR"={calculation="TARGET"}}
6767
bulk_binding_model = "AVERAGE"

examples/lithium_vapor_shield.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,5 +63,5 @@ Ec = [ 1.0, 1.0 ]
6363
Z = [ 3, 3 ]
6464
m = [ 6.94, 6.94 ]
6565
interaction_index = [ 0, 0 ]
66-
surface_binding_model = "INDIVIDUAL"
66+
surface_binding_model = {"PLANAR"={calculation="TARGET"}}
6767
bulk_binding_model = "INDIVIDUAL"

examples/multiple_interaction_potentials.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,5 +60,5 @@ Ec = [ 3.5, 2.0, 3.0, 1.5,]
6060
Z = [ 22, 8, 13, 14,]
6161
m = [ 47.867, 15.9994, 26.98, 28.08553,]
6262
interaction_index = [0, 0, 0, 0]
63-
surface_binding_model = "TARGET"
63+
surface_binding_model = {"PLANAR"={calculation="TARGET"}}
6464
bulk_binding_model = "AVERAGE"

examples/titanium_dioxide_0D.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,5 +62,5 @@ Ec = [ 3.5, 2.0, 3.0, 1.5,]
6262
Z = [ 22, 8, 13, 14,]
6363
m = [ 47.867, 15.9994, 26.98, 28.08553,]
6464
interaction_index = [0, 0, 0, 0]
65-
surface_binding_model = "TARGET"
65+
surface_binding_model = {"PLANAR"={calculation="TARGET"}}
6666
bulk_binding_model = "AVERAGE"

src/enums.rs

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ impl fmt::Display for ElectronicStoppingMode {
4141

4242
/// Mode of surface binding energy calculation.
4343
#[derive(Deserialize, PartialEq, Clone, Copy)]
44-
pub enum SurfaceBindingModel {
44+
pub enum SurfaceBindingCalculation {
4545
/// Surface binding energies will be determined individually depending only on the particle's `Es`.
4646
INDIVIDUAL,
4747
/// Surface binding energies will be a concentration-weighted average of material surface-binding energies, unless `particle.Es == 0` in which case it will be zero.
@@ -50,19 +50,38 @@ pub enum SurfaceBindingModel {
5050
AVERAGE,
5151
}
5252

53-
impl fmt::Display for SurfaceBindingModel {
53+
impl fmt::Display for SurfaceBindingCalculation {
5454
fn fmt (&self, f: &mut fmt::Formatter) -> fmt::Result {
5555
match *self {
56-
SurfaceBindingModel::INDIVIDUAL => write!(f,
56+
SurfaceBindingCalculation::INDIVIDUAL => write!(f,
5757
"Individual surface binding energies."),
58-
SurfaceBindingModel::TARGET => write!(f,
58+
SurfaceBindingCalculation::TARGET => write!(f,
5959
"Concentration-dependent linear combinaion of target binding energies."),
60-
SurfaceBindingModel::AVERAGE => write!(f,
60+
SurfaceBindingCalculation::AVERAGE => write!(f,
6161
"Average between particle and concentration-dependent linear combination of target binding energies."),
6262
}
6363
}
6464
}
6565

66+
#[derive(Deserialize, PartialEq, Clone, Copy)]
67+
pub enum SurfaceBindingModel {
68+
/// Isotropic surface binding potential - results in no refraction
69+
ISOTROPIC{calculation: SurfaceBindingCalculation},
70+
/// Planar surface binding potential - particles refract through potential
71+
PLANAR{calculation: SurfaceBindingCalculation}
72+
}
73+
74+
impl fmt::Display for SurfaceBindingModel {
75+
fn fmt (&self, f: &mut fmt::Formatter) -> fmt::Result {
76+
match *self {
77+
SurfaceBindingModel::ISOTROPIC{..} => write!(f,
78+
"Locally isotropic surface binding energy."),
79+
SurfaceBindingModel::PLANAR{..} => write!(f,
80+
"Locally planar surface binding energy."),
81+
}
82+
}
83+
}
84+
6685
/// Mode of bulk binding energy calculation.
6786
#[derive(Deserialize, PartialEq, Clone, Copy)]
6887
pub enum BulkBindingModel {

src/material.rs

Lines changed: 34 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -184,24 +184,27 @@ impl <T: Geometry + GeometryInput> Material<T> {
184184
let concentrations = self.geometry.get_concentrations(x, y, z);
185185

186186
match self.surface_binding_model {
187-
SurfaceBindingModel::INDIVIDUAL => particle.Es,
188-
189-
SurfaceBindingModel::TARGET => {
190-
if particle.Es == 0. {
191-
0.
192-
} else {
193-
self.Es.iter().zip(concentrations).map(|(surface_binding_energy, concentration)| surface_binding_energy*concentration).collect::<Vec<f64>>().iter().sum()
194-
}
195-
},
196-
197-
SurfaceBindingModel::AVERAGE => {
198-
if (particle.Es == 0.) | (self.Es.iter().sum::<f64>() == 0.) {
199-
0.
200-
} else {
201-
0.5*(particle.Es + self.Es.iter().zip(concentrations).map(|(surface_binding_energy, concentration)| surface_binding_energy*concentration).collect::<Vec<f64>>().iter().sum::<f64>())
187+
SurfaceBindingModel::ISOTROPIC{calculation} | SurfaceBindingModel::PLANAR{calculation} => {
188+
match calculation {
189+
SurfaceBindingCalculation::INDIVIDUAL => particle.Es,
190+
191+
SurfaceBindingCalculation::TARGET => {
192+
if particle.Es == 0. {
193+
0.
194+
} else {
195+
self.Es.iter().zip(concentrations).map(|(surface_binding_energy, concentration)| surface_binding_energy*concentration).collect::<Vec<f64>>().iter().sum()
196+
}
197+
},
198+
199+
SurfaceBindingCalculation::AVERAGE => {
200+
if (particle.Es == 0.) | (self.Es.iter().sum::<f64>() == 0.) {
201+
0.
202+
} else {
203+
0.5*(particle.Es + self.Es.iter().zip(concentrations).map(|(surface_binding_energy, concentration)| surface_binding_energy*concentration).collect::<Vec<f64>>().iter().sum::<f64>())
204+
}
205+
},
202206
}
203-
},
204-
207+
}
205208
}
206209
}
207210

@@ -327,9 +330,13 @@ pub fn surface_binding_energy<T: Geometry>(particle_1: &mut particle::Particle,
327330
let costheta = dx*cosx/mag + dy*cosy/mag + dz*cosz/mag;
328331
particle_1.E += Es;
329332

330-
//Surface refraction through energy barrier via Snell's law
331-
let delta_theta = particle::refraction_angle(costheta, E, E + Es);
332-
particle::rotate_particle(particle_1, delta_theta, 0.);
333+
match material.surface_binding_model {
334+
SurfaceBindingModel::PLANAR{..} => {
335+
let delta_theta = particle::refraction_angle(costheta, E, E + Es);
336+
particle::rotate_particle(particle_1, delta_theta, 0.);
337+
}
338+
_ => ()
339+
}
333340
}
334341
}
335342

@@ -348,9 +355,13 @@ pub fn surface_binding_energy<T: Geometry>(particle_1: &mut particle::Particle,
348355

349356
particle_1.E += -Es;
350357

351-
//Surface refraction via Snell's law
352-
let delta_theta = particle::refraction_angle(costheta, E, E - Es);
353-
particle::rotate_particle(particle_1, delta_theta, 0.);
358+
match material.surface_binding_model {
359+
SurfaceBindingModel::PLANAR{..} => {
360+
let delta_theta = particle::refraction_angle(costheta, E, E + Es);
361+
particle::rotate_particle(particle_1, delta_theta, 0.);
362+
}
363+
_ => ()
364+
}
354365

355366
} else {
356367

0 commit comments

Comments
 (0)