Commit 10ad95fd authored by sfritschi's avatar sfritschi
Browse files

Freeing of no longer needed resources

parent 7d243bad
...@@ -20,7 +20,7 @@ def main(): ...@@ -20,7 +20,7 @@ def main():
print("Min. number of throats per pore: %d" % min(pore_throat_counts)) print("Min. number of throats per pore: %d" % min(pore_throat_counts))
print("Avg. number of throats per pore: %f" % (sum(pore_throat_counts) / len(pore_throat_counts))) print("Avg. number of throats per pore: %f" % (sum(pore_throat_counts) / len(pore_throat_counts)))
target = [5, 5, 5] target = [3, 3, 3]
print("Target size: {}".format(target)) print("Target size: {}".format(target))
cutoff = 0.5 * max([basenet.ub[i] - basenet.lb[i] \ cutoff = 0.5 * max([basenet.ub[i] - basenet.lb[i] \
for i in range(len(basenet.ub))]) for i in range(len(basenet.ub))])
......
#!/bin/bash #!/bin/bash
bsub -n 48 -W 00:20 -R fullnode python3 generate.py 48 bsub -n 48 -W 00:30 -R fullnode python3 generate.py 48
...@@ -740,7 +740,7 @@ def generate_dendrogram(basenet: Network, targetsize: List[int], \ ...@@ -740,7 +740,7 @@ def generate_dendrogram(basenet: Network, targetsize: List[int], \
# dendrogram-based or uniform pore distribution # dendrogram-based or uniform pore distribution
pores = [] pores = []
if (cutoff != cutoff): # uniform if (cutoff != cutoff): # uniform
print("\b"*21 + "uniform pore distribution") print("uniform pore distribution")
# loop over network sections & add uniformly distributed pores drawn from basenet # loop over network sections & add uniformly distributed pores drawn from basenet
runningIndex = 0 runningIndex = 0
for s in product(*[range(k) for k in targetsize]): for s in product(*[range(k) for k in targetsize]):
...@@ -788,7 +788,7 @@ def generate_dendrogram(basenet: Network, targetsize: List[int], \ ...@@ -788,7 +788,7 @@ def generate_dendrogram(basenet: Network, targetsize: List[int], \
pores.insert(randint(0,len(pores)), Pore(pos=pos, pores.insert(randint(0,len(pores)), Pore(pos=pos,
r=pore.r, label=LABELS[0], throats=pore.throats.copy())) r=pore.r, label=LABELS[0], throats=pore.throats.copy()))
print("\b"*21 + "left {0:d} of {1:d} clusters (incl. {2:d} pores) untouched".\ print("left {0:d} of {1:d} clusters (incl. {2:d} pores) untouched".\
format(sum([int(not j) for j in touched]), len(touched), len(basepores))) format(sum([int(not j) for j in touched]), len(touched), len(basepores)))
# flip pores outside back into domain and set respective index of all pores # flip pores outside back into domain and set respective index of all pores
for i, pore in enumerate(pores): for i, pore in enumerate(pores):
...@@ -845,6 +845,8 @@ def generate_dendrogram(basenet: Network, targetsize: List[int], \ ...@@ -845,6 +845,8 @@ def generate_dendrogram(basenet: Network, targetsize: List[int], \
total = 0 total = 0
n_already_taken = 0 n_already_taken = 0
for poreIdx, pore in enumerate(pores[:n]): for poreIdx, pore in enumerate(pores[:n]):
# Delete throats (not needed anymore)
pore.throats.clear()
if (not mute): if (not mute):
print(f"progress {((poreIdx+1) / n)*100.:.1f}%", end="\r", flush=True) print(f"progress {((poreIdx+1) / n)*100.:.1f}%", end="\r", flush=True)
...@@ -1001,11 +1003,14 @@ def generate_dendrogram(basenet: Network, targetsize: List[int], \ ...@@ -1001,11 +1003,14 @@ def generate_dendrogram(basenet: Network, targetsize: List[int], \
print("Avg. throat length difference: %e" % avg_throat_diff) print("Avg. throat length difference: %e" % avg_throat_diff)
print("Relative to Lmax: %.1f%%" % (avg_throat_diff / basenet.Lmax * 100.)) print("Relative to Lmax: %.1f%%" % (avg_throat_diff / basenet.Lmax * 100.))
print("Percentage where match was fully-connected: %.1f%%" % (n_already_taken / total * 100.)) print("Percentage where match was fully-connected: %.1f%%" % (n_already_taken / total * 100.))
# Free memory associated with cellList (not needed anymore)
del cellList
# assemble and return network # assemble and return network
network = Network(lb=[0.0 for k in range(d)], network = Network(lb=[0.0 for k in range(d)],
ub=L, Lmax=basenet.Lmax, label='from_' + basenet.label) ub=L, Lmax=basenet.Lmax, label='from_' + basenet.label)
for pore in pores[:n]: for pore in pores[:n]:
pore.throats.clear() # Remove throats
network.add_pore(pore) network.add_pore(pore)
for throat in throats: network.connect_pores(pore1=throat[0], for throat in throats: network.connect_pores(pore1=throat[0],
pore2=throat[1], label=throat[2], r=throat[3]) pore2=throat[1], label=throat[2], r=throat[3])
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment