Skip to content

Commit 6a68d14

Browse files
authored
Fixed: CANN material model gives NaN values for a particular activation function choice (SimVascular#410)
* Added edge case and removed some commented code * Added integration test with artery material model on LV geometry
1 parent b7420d8 commit 6a68d14

File tree

13 files changed

+169
-18
lines changed

13 files changed

+169
-18
lines changed

Code/Source/solver/ArtificialNeuralNetMaterial.cpp

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,16 @@ void ArtificialNeuralNetMaterial::uCANN_h0(const double x, const int kf, double
4747
df = 1;
4848
ddf = 0;
4949
} else if (kf == 2) {
50-
f = (std::abs(x) + x) / 2;
51-
df = 0.5 * (std::abs(x) / x + 1);
52-
ddf = 0;
50+
if (x == 0) {
51+
f = (std::abs(x) + x) / 2;
52+
df = 0;
53+
ddf = 0;
54+
}
55+
else {
56+
f = (std::abs(x) + x) / 2;
57+
df = 0.5 * (std::abs(x) / x + 1);
58+
ddf = 0;
59+
}
5360
} else if (kf == 3) {
5461
f = std::abs(x);
5562
df = std::abs(x) / x;

Code/Source/solver/distribute.cpp

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1241,21 +1241,7 @@ void dist_mat_consts(const ComMod& com_mod, const CmMod& cm_mod, const cmType& c
12411241
cm.bcast(cm_mod, lStM.paramTable.weights, "paramTable.weights");
12421242
}
12431243
}
1244-
// cm.bcast(cm_mod, &lStM.paramTable.num_rows);
1245-
1246-
// if (lStM.paramTable.num_rows > 0) {
1247-
// if (cm.slv(cm_mod))
1248-
// {
1249-
// lStM.paramTable.invariant_indices.resize(lStM.paramTable.num_rows);
1250-
// lStM.paramTable.activation_functions.resize(lStM.paramTable.num_rows,3);
1251-
// lStM.paramTable.weights.resize(lStM.paramTable.num_rows,3);
1252-
// }
1253-
1254-
// cm.bcast(cm_mod, lStM.paramTable.invariant_indices);
1255-
// cm.bcast(cm_mod, lStM.paramTable.activation_functions, "paramTable.act_func");
1256-
// cm.bcast(cm_mod, lStM.paramTable.weights, "paramTable.weights");
1257-
// }
1258-
1244+
12591245
}
12601246

12611247

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
version https://git-lfs.github.com/spec/v1
2+
oid sha256:3cf8ccb1b43920269cf72e84d8a5332c053a1a24865ce845284987aa1a3872ad
3+
size 20865
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
version https://git-lfs.github.com/spec/v1
2+
oid sha256:de695cbe805a262926972c8d2e59be6d82f43bbb0e10e6e0bb4780832b32cc0d
3+
size 93997
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
version https://git-lfs.github.com/spec/v1
2+
oid sha256:00ce8af58380bc6f682a5fbab0473818eeeb9f8024b419fbe928d38f5f8e34ec
3+
size 99744
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
version https://git-lfs.github.com/spec/v1
2+
oid sha256:516ca5f67f51c432410c65a1f98d73baca653b0378664607a20eba3fd5e94db4
3+
size 19832
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
version https://git-lfs.github.com/spec/v1
2+
oid sha256:9b7c72acb6c365fae7c33091f8d932c95863d95ffee7fed934a2f832aeba976d
3+
size 27192
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
version https://git-lfs.github.com/spec/v1
2+
oid sha256:4028808552b03a2854ce33bf5016243c6b994e62a61928625691b72938f1480d
3+
size 10038
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
version https://git-lfs.github.com/spec/v1
2+
oid sha256:f125c7001fc4a5ad90313fcff8ef24749ccd054a6b045521dfc3d06169160a09
3+
size 11982
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
version https://git-lfs.github.com/spec/v1
2+
oid sha256:2050d191642b719f651de6587571a7021eff67801eddd97c0fec397f3e9b62cd
3+
size 3940

0 commit comments

Comments
 (0)