-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: TemperatureSchedule module (#1892)
- Loading branch information
1 parent
d572e8c
commit 205b28d
Showing
11 changed files
with
232 additions
and
1 deletion.
There are no files selected for viewing
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -45,6 +45,7 @@ enum ModuleType | |
SiteRDF, | ||
Skeleton, | ||
SQ, | ||
TemperatureSchedule, | ||
Test, | ||
XRaySQ | ||
}; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
dissolve_add_module(temperatureSchedule.h temperatureSchedule) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
// SPDX-License-Identifier: GPL-3.0-or-later | ||
// Copyright (c) 2024 Team Dissolve and contributors | ||
|
||
#include "classes/configuration.h" | ||
#include "modules/temperatureSchedule/temperatureSchedule.h" | ||
|
||
// Run main processing | ||
Module::ExecutionResult TemperatureScheduleModule::process(ModuleContext &moduleContext) | ||
{ | ||
// Check for zero Configuration targets | ||
if (!targetConfiguration_) | ||
{ | ||
Messenger::error("No configuration target set for module '{}'.\n", name()); | ||
return ExecutionResult::Failed; | ||
} | ||
|
||
// Get the current configuration temperature | ||
auto currentT = targetConfiguration_->temperature(); | ||
|
||
// Get difference with tergat temperature | ||
auto diffT = targetTemperature_ - currentT; | ||
|
||
// Get move amount | ||
auto deltaT = DissolveMath::sgn(diffT) * std::min(fabs(diffT), rate_); | ||
|
||
Messenger::print("Difference between current and target temperatures is {} K.\n", fabs(diffT)); | ||
Messenger::print("New temperature will be {} K (rate max = {} K / iteration).\n", currentT + deltaT, rate_); | ||
|
||
targetConfiguration_->setTemperature(currentT + deltaT); | ||
|
||
return ExecutionResult::Success; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
// SPDX-License-Identifier: GPL-3.0-or-later | ||
// Copyright (c) 2024 Team Dissolve and contributors | ||
|
||
#include "modules/temperatureSchedule/temperatureSchedule.h" | ||
#include "keywords/configuration.h" | ||
#include "keywords/double.h" | ||
|
||
TemperatureScheduleModule::TemperatureScheduleModule() : Module(ModuleTypes::TemperatureSchedule) | ||
{ | ||
keywords_.addTarget<ConfigurationKeyword>("Configuration", "Set target configuration for the module", targetConfiguration_); | ||
|
||
keywords_.setOrganisation("Options", "Schedule", "Control rate of temperature change on the target configuration."); | ||
keywords_.add<DoubleKeyword>("TargetTemperature", "Target temperature, in Kelvin, to move towards", targetTemperature_, | ||
0.0); | ||
keywords_.add<DoubleKeyword>( | ||
"Rate", "Rate of temperature change, in Kelvin per iteration, to move towards target temperature", rate_, 0.0); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
// SPDX-License-Identifier: GPL-3.0-or-later | ||
// Copyright (c) 2024 Team Dissolve and contributors | ||
|
||
#pragma once | ||
|
||
#include "module/module.h" | ||
|
||
// TemperatureSchedule Module | ||
class TemperatureScheduleModule : public Module | ||
{ | ||
public: | ||
TemperatureScheduleModule(); | ||
~TemperatureScheduleModule() override = default; | ||
|
||
/* | ||
* Definition | ||
*/ | ||
private: | ||
// Target configuration | ||
Configuration *targetConfiguration_{nullptr}; | ||
// Target temperature | ||
double targetTemperature_{300.0}; | ||
// Rate of change, Kelvin per iteration | ||
double rate_{1.0}; | ||
|
||
/* | ||
* Processing | ||
*/ | ||
private: | ||
// Run main processing | ||
Module::ExecutionResult process(ModuleContext &moduleContext) override; | ||
}; |
23 changes: 23 additions & 0 deletions
23
web/docs/userguide/modules/evolution/temperatureschedule/_index.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
--- | ||
title: TemperatureSchedule (Module) | ||
linkTitle: TemperatureSchedule | ||
description: Control the temperature of a configuration | ||
--- | ||
|
||
## Overview | ||
|
||
The `TemperatureSchedule` module gives the ability to control the temperature of a configuration, adjusting its towards some target temperature at a predefined maximum rate per iteration of the module. | ||
|
||
### Targets | ||
|
||
|Keyword|Arguments|Default|Description| | ||
|:------|:--:|:-----:|-----------| | ||
|`Configuration`|`Configuration`|--|{{< required-label >}}Target configuration on which to operate.| | ||
|
||
### Schedule | ||
|
||
|Keyword|Arguments|Default|Description| | ||
|:------|:--:|:-----:|-----------| | ||
|`Rate`|`double`|`1.0`|Maximal absolute change to add or subtract from the configuration's current temperature each time the module runs in order to move it towards the target temperature. If the difference between the target and current temperatures is less than the defined rate, the configuration temperature is set to the target temperature.| | ||
|`TargetTemperature`|`double`|`300.0`|Target temperature for the configuration.| | ||
|