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

fix: change TOML config file to use MD #84

Merged
merged 14 commits into from
Oct 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 0 additions & 37 deletions .github/workflows/semantic-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ jobs:
permissions:
id-token: write
contents: write
pull-requests: write

steps:
- name: Harden Runner
Expand All @@ -40,27 +39,8 @@ jobs:
run: |
echo "short_sha=$(git rev-parse --short HEAD)\n" >> $GITHUB_OUTPUT

- name: Action | Check if release is needed
id: check
# Adjust tag with desired version if applicable.
uses: python-semantic-release/python-semantic-release@c1bcfdbb994243ac7cf419365d5894d6bfb2950e # v9.12.0
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
git_committer_name: "github-actions"
git_committer_email: "[email protected]"
root_options: -vv --noop
build: false
changelog: true
commit: false
push: false
tag: false
vcs_release: false
# prerelease: true
# build_metadata: ${{ github.ref_name }}@${{ steps.vars.outputs.short_sha }}

- name: Action | Semantic Release - Update version
id: release
if: steps.check.outputs.released == 'true'
# Adjust tag with desired version if applicable.
uses: python-semantic-release/python-semantic-release@c1bcfdbb994243ac7cf419365d5894d6bfb2950e # v9.12.0
with:
Expand All @@ -73,20 +53,3 @@ jobs:
push: true
tag: true
vcs_release: false
prerelease: true
prerelease_token: rc
build_metadata: ${{ steps.vars.outputs.short_sha }}

- name: Action | Create Pull Request - Release
if: steps.check.outputs.released == 'true'
run: |
gh pr create -B main -H staging --title "release: Merge into main and create tag as v${{ steps.release.outputs.version }}" --body 'Created by Github action: semantic-release.yml'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Action | Create Pull Request - Chore
if: steps.check.outputs.released == 'false'
run: |
gh pr create -B main -H staging --title 'chore: Merge non-code changes into main' --body 'Created by Github action: semantic-release.yml'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ sansmic = "src/python/sansmic"
[tool.semantic_release]
assets = []
build_command_env = []
commit_message = "release: {version}\n\nAutomatically generated by python-semantic-release"
commit_message = "chore: update version text to {version}\n\nAutomatically generated by python-semantic-release"
commit_parser = "angular"
logging_use_named_masks = false
major_on_zero = true
Expand Down
8 changes: 3 additions & 5 deletions src/ext_modules/libsansmic/libsansmic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,12 @@ PYBIND11_MODULE(libsansmic, m) {

py::enum_<sansmic::LeachMode>(m, "CRunMode",
"See :py:class:`sansmic.model.SimulationMode`.")
.value("ORDINARY", sansmic::LeachMode::Ordinary,
.value("ORDINARY", sansmic::LeachMode::ORDINARY,
"ordinary leaching (water in, brine out)")
.value("WITHDRAWAL", sansmic::LeachMode::Withdrawal,
.value("WITHDRAWAL", sansmic::LeachMode::WITHDRAWAL,
"oil withdrawal (water in, oil out)")
.value("LEACH_FILL", sansmic::LeachMode::LeachFill,
.value("LEACH_FILL", sansmic::LeachMode::LEACH_FILL,
"leach and fill (water and oil in, brine out)")
.value("OIL_FILL", sansmic::LeachMode::OilFill,
"oil fill (oil in, brine out)")
.export_values();

py::enum_<sansmic::GeomFormat>(
Expand Down
7 changes: 3 additions & 4 deletions src/ext_modules/libsansmic/libsansmic.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,9 @@ const int UNIMPLEMENTED_GEOMETRY_IDATA =

/// @brief The leaching operations mode for sansmic.
enum LeachMode : int {
Ordinary = 0, //!< fill with raw water, produce brine
Withdrawal = 1, //!< fill with raw water, produce oil
LeachFill = 2, //!< fill with oil and raw water, produce brine
OilFill = -1 //!< fill with oil, produce brine
ORDINARY = 0, //!< fill with raw water, produce brine
WITHDRAWAL = 1, //!< fill with raw water, produce oil
LEACH_FILL = 2, //!< fill with oil and raw water, produce brine
};

/// @brief The format of the data; will go away once python code fully handles
Expand Down
41 changes: 20 additions & 21 deletions src/ext_modules/libsansmic/model.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -334,21 +334,16 @@ int sansmic::Model::init_stage(void) {
z_obi_stop = -double(stopCriteria);
}

// if the current depths are below zero (?) set to the
// height of the insolubles plus the absolute height given
// I.e., consider that these are relative heights above the
// level of the insoluble materials not absolute heights.
// Version 1.1.0: removed relative heights above new floor height as negatives
// Version 1.1.0: Negative values will be considered depths below surface
if (h_inj < 0) {
h_inj = h_insol - h_inj;
h_inj = z_TD0 + h_inj;
}
if (h_prd < 0) {
h_prd = h_insol - h_prd;
h_prd = z_TD0 + h_prd;
}
if (h_obi < 0) {
h_obi = h_insol - h_obi;
}
if (h_uso < 0) {
h_uso = h_insol - h_uso;
h_obi = z_TD0 + h_obi;
}

// use previous OBI if OBI is ~0
Expand Down Expand Up @@ -401,7 +396,7 @@ int sansmic::Model::init_stage(void) {
C_cav[n_nodes] = C_hat;
C_cavAve = C_cav0;

if (runMode == Withdrawal) {
if (runMode == WITHDRAWAL) {
dt_min = (_pi_ * sq(r_cavMin) * dz) / (Q_in + 1.0e-10);
if (dt_min < 0.01) {
dt_min = 0.01;
Expand All @@ -415,7 +410,7 @@ int sansmic::Model::init_stage(void) {
f_disSav[i] = f_dis[i];
}
// FIXME: do we really want this next line?
if (runMode == Withdrawal && C_cav0 > 1.0) {
if (runMode == WITHDRAWAL && C_cav0 > 1.0) {
std::fill(C_cav.begin(), C_cav.end(), C_cav0);
C_cav[n_nodes] = C_hat;
C_cavAve = C_cav0;
Expand Down Expand Up @@ -449,7 +444,7 @@ int sansmic::Model::init_stage(void) {
// End of initialization of cavern settings

// set the prod and min timestep if withdrawal leach
if (runMode == Withdrawal) {
if (runMode == WITHDRAWAL) {
prodCell = obiCell;
dt_min = (_pi_ * sq(r_cavMin) * dz) / (Q_in + 1.0e-10);
// next two lines are commented out?
Expand Down Expand Up @@ -575,6 +570,8 @@ int sansmic::Model::leach() {
throw sansmic::UNIMPLEMENTED_FLOW_TABLES;
}

double t_add = 0;

// Convert back to BPD? Ugh.
Q_inBPD = Q_in * cf_to_bbl * per_h_to_per_d;
Q_fillBPD = Q_fill * cf_to_bbl * per_h_to_per_d;
Expand Down Expand Up @@ -707,7 +704,7 @@ int sansmic::Model::leach() {
// end of adjust the plume model (reverse)

// leach fill from production to OBI
if (runMode >= LeachFill) {
if (runMode >= LEACH_FILL) {
for (int i = prodCell; i <= obiCell; i++) {
if (i > maxProdOrJet) {
V_injSigned[i] = 0.0;
Expand Down Expand Up @@ -782,7 +779,7 @@ int sansmic::Model::leach() {
if (i < minProdOrJet || i > maxProdOrJet) {
V_injSigned[i] = 0.0;
}
if (i > maxProdOrJet && runMode == LeachFill) {
if (i > maxProdOrJet && runMode == LEACH_FILL) {
V_injSigned[i] = -Q_fill;
}
r = max(r_cav[i], 1.0e-10);
Expand Down Expand Up @@ -1086,14 +1083,14 @@ int sansmic::Model::leach() {

izbs = obiCell;
// move OBI if not Ordinary leaching mode
if (runMode == LeachFill) {
if (runMode == LEACH_FILL) {
// move OBI if simultaneous LeachFill
i_obi = int(h_obi / dz) + 1;
dz_inc = Q_fill * dt / (_pi_ * sq(r_cav[i_obi]));
h_obi = h_obi - min(dz_inc, dz);
obiCell = int(h_obi / dz + 0.5) + 1;
obiCellBelow = obiCell - 1;
} else if (runMode != Ordinary) {
} else if (runMode != ORDINARY) {
// move OBI if Withdrawal or OilFill
i_obiOld = obiCell;
i_obi = int(h_obi / dz) + 1;
Expand All @@ -1115,9 +1112,9 @@ int sansmic::Model::leach() {

// CALCULATE MASS BALANCE CORRECTION FACTOR
m_brineNew = m_brineNew - V_insol * C_cav[1];
if (runMode == Ordinary) {
if (runMode == ORDINARY) {
Q_fill = 0.0;
} else if (runMode == Withdrawal) {
} else if (runMode == WITHDRAWAL) {
Q_fill = -ddim(Q_out, 0.0);
}
p5 = Q_fill;
Expand Down Expand Up @@ -1205,11 +1202,13 @@ int sansmic::Model::leach() {
if (b_is_injecting) {
if (abs(z_obi - z_obi_stop) < 0.1 * dz) {
t_end = t;
} else if (runMode != LeachFill && z_obi < z_obi_stop) {
} else if (runMode == WITHDRAWAL && z_obi <= z_obi_stop) {
t_end = t;
} else if (z_obi > z_obi_stop) {
} else if (runMode == LEACH_FILL && z_obi >= z_obi_stop) {
t_end = t;
}
// dbh: there probably ought to be an exception check for ordinary
// mode, but the OBI doesn't move so it should be impossible to reach
}
}
// stop on time - clear the handling variables
Expand Down
2 changes: 1 addition & 1 deletion src/ext_modules/libsansmic/stage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
*/
sansmic::Stage::Stage() {
title = "";
leach_mode = Withdrawal;
leach_mode = WITHDRAWAL;
print_freq = -1;
is_subsequent = 0;
t_rest = -1;
Expand Down
15 changes: 11 additions & 4 deletions src/python/sansmic/io.py
Original file line number Diff line number Diff line change
Expand Up @@ -335,11 +335,18 @@ def read_dat(str_or_buffer: Union[str, Path], *, ignore_errors=False) -> Scenari
stage.stop_value = float(stop_value)
if stage.stop_value < 0:
stage.stop_condition = StopCondition.DEPTH
if stage.stop_value > 0:
stage.stop_value = scenario.floor_depth + stage.stop_value
elif stage.stop_value > 0:
stage.stop_condition = StopCondition.VOLUME
stage.brine_injection_depth = float(injection_height)
stage.brine_production_depth = float(production_height)
stage.brine_interface_depth = float(interface_height)
stage.brine_injection_depth = scenario.floor_depth - float(injection_height)
stage.brine_production_depth = scenario.floor_depth - float(
production_height
)
stage.brine_interface_depth = (
scenario.floor_depth - float(interface_height)
if float(interface_height) != 0
else 0
)
stage.brine_injection_rate = float(injection_rate)
stage.inner_tbg_inside_diam = float(inn_tbg_inside_radius) * 2
stage.inner_tbg_outside_diam = float(inn_tbg_outside_radius) * 2
Expand Down
Loading