Skip to content

Commit

Permalink
add smoothing fxn
Browse files Browse the repository at this point in the history
  • Loading branch information
miketynes committed Aug 2, 2024
1 parent e72a960 commit 97baec9
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion cascade/proxima/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ class SerialLearningCalculator(Calculator):
Determines when to switch between the physics and learnable calculator based
on an uncertainty metric from the learnable calculator.
Switching can be applied smoothly, that is by taking a mixture of physics-
and surrogate-derived quantities that moves slowly toward full surrogate
utilization over time. This is controleld by the parameters n_blending_steps
Parameters for the calculator are:
target_calc: BaseCalculator
Expand Down Expand Up @@ -116,6 +120,11 @@ def implemented_properties(self) -> List[str]:
@property
def learner(self) -> BaseLearnableForcefield:
return self.parameters['learner']

@classmethod
def smoothing_function(x):
"""Smoothing used for blending surrogate with physics"""
return 0.5*(np.cos(np.pi*x)) + 1

def retrain_surrogate(self):
"""Retrain the surrogate models using the currently-available data"""
Expand Down Expand Up @@ -212,7 +221,7 @@ def calculate(

if self.used_surrogate and blend_with_target:
# return a blend if appropriate
lambda_target = blend_with_target / self.n_blend_steps
lambda_target = self.smoothing_function(blend_with_target / self.n_blend_steps)
results_target = target_calc.results.copy()
results_surrogate = self.surrogate_calc.results.copy()
self.results = {}
Expand Down

0 comments on commit 97baec9

Please sign in to comment.