Files
LBPM/example/PlaneMembrane/plane_membrane.py
James E. McClure fac681dffe Rc 08.15.2022 (#70)
* summit configure

* add spock scripts to FOM

* get new models to build with hip

* add hip slipping bc

* testing communication on spock

* update spock build based on olcf docs

* update configure & test scripts for spock

* Fixing potential bugs with communication

* Adding simple test of GPU aware MPI

* some changes to configure for spock

* Modifying GPU aware MPI test to send multiple messages

* playing with spock Gpu test

* added gpu wrapper test

* Cleaning up some compiler warnings

* add barrier between pack / MPI send

* Updating build to support HIP as a language

* fixing gpu mpi sync

* Adding script

* local spock changes

* add membrane class

* update membrane structure

* membrane communications

* working on new comm data structures

* add membrane unit test

* membrane compiles

* membrane test

* Updating hip port to match cuda

* update summit config

* update summit config

* add configure script for crusher

* update membrane test

* update membrane test

* convention for inside / outside membrane link direction

* working on membrane comm

* try to fix time conversion factor for Poisson solver; to be built and tested

* fix dumb typo

* update summit config

* tune launch for crusher

* tune launch for mrt on crusher

* update color

* summit script with specific module versions

* update crusher config

* add crusher examples

* add dense case for crusher

* Fixing some quick annoying compile warnings

* fix binding in example

* working on fix

* Adding simple crusher test

* Adding new crusher MPI test

* disable MPI thread multiple for crusher

* updates to crusher configure

* cpu test for crusher

* Working on standalone reproducer for MPI bug

* More work on creating standalone test

* More work on creating standalone test

* More work on creating standalone test

* Reverting TestCrusher2, standalone version passes (TestCrusher3.cpp), need to figure out why

* Working on standalone MPI test on crusher

* Working on standalone MPI test on crusher

* Getting closer to stand alone test

* Still trying to create standalone reproducer

* hang fix / workaround

* Created standalone MPI failure test

* Removing TestCrusher tests, the bug deals with the StackTrace which we disable the multistack trace for now.  Moving the test out of LBPM

* fix sendcount / recvcount

* Testing persistent communication

* Updating calculation of bandwidth

* crusher hackathon final version

* working on membrane communication structures

* add cell simulator

* added cell simulator

* make sure halo is filled when measuring object

* add membrane transport function for d3q7

* add membrane unpack function

* poking at MF issue

* update crusher build

* membrane data structures compiling

* update to membrane capability

* update comments in ion model

* fix dumb print bug

* clean up relabel

* adding membrane functions

* move membrane to common folder

* membrane structure in IonModel

* membrane structure in IonModel

* try at membrane simulator

* add python script to generate bubble

* add python script to generate bubble

* cell simulator runs

* read input files

* add single cell example

* refining cell example

* start on cuda function

* werkin

* start on cuda function

* start on hip function

* updates and fix for user input reader

* update cell example

* add sigmoid to ion equilibrium dist

* cuda build succeeds

* update crusher script

* getting ready to merge gpu

* refactor compact AA routines for testing

* add testing functions to ScaLBL

* testing membrane ion transport

* membrane transport test passing

* membrane starts working ok...

* original wang poisson solver (broken)

* rex d3q19 (broken)

* tau from wang paper

* still broken wang

* d319 poisson works good

* Poisson working pretty good now

* initialize nernst-planck simulator; to be built subject to debugging

* fix a few syntax bugs and build passed

* Poisson solver; enable specifying initial values

* update cell example

* add GPU functions for d3q19 poisson

* fix dumb bugs

* fix bugs in initializing electric potential; the Psi on solid was accidentally overwritten before.

* small change

* fix bugs in importing ion model's dummy velocity

* add membrane concentration init

* remove bad warnings

* remove print staetements

* add barriers to poisson solver

* update print

* print membrane input concentration

* read Membrane ion concentration list

* fix bad ref to D3Q7

* update error analysis for Poisson solver

* fix typo

* update hip poisson solver

* deprecate old error methods

* a bunch of summit debug things to roll back later

* fix poisson typo

* update hip

* debug crusher

* debug charge density problems on crusher

* fix charge density (i think)

* remove Stokes solver from cell simulator; need to test build

* update cpu ion valence

* added membrane properties to input db

* update cell db

* update executable list and NP_cell simulator

* correct use_membrane functionality

* add functionality for user to choose either D3Q7 or D3Q19 lattice for Poisson;to be built and tested

* build passed

* make further corrections

* correct D3Q7 Poisson LB algorithm

* correct ion LB collison

* udpate output precision

* add more tweaks for cell simulator

* update print-out

* this makes mpi hang error explicit;to be debugged

* cleanup with help from valgrind

* update to cell vis routine

* add hip for ion update

* fix missing bracket

* add new ion code for cuda

* add barrier to membrane transport

* debug gpu launch issue for ion

* debug gpu

* add functions to copy send / recv list from ScaLBL

* updating membrane communication structure

* membrane test works with new comm

* communication seems to work

* add sample files for plane membrane

* update gpu routines first try

* update hip

* multiple nvidia gpu working with membrane

* added membrane analysis capability

* added support for swc file

* support for SWC input format

* swc reader works with MPI

* shift swc data

* SWC reader update

* SWC reader update 2

* add offset to Domain for swc

* add input files for simple bacteria

* add performance counters to ion / poisson solvers

* fix bug with SWC

* add BC to poisson solver

* fix compiler warnings

* fix memory leaks

* fix zlib download path

* Fixing memory leak

* Fixing memory leaks

* restart for Poisson model

* fix bug in ion model restart

* trying to fix yaml

* fix workflow indentation

* porosity factor in effperm

* porosity factor in effperm

* porosity factor in effperm

* porosity factor in effperm

Co-authored-by: James E McClure <mcclurej@vt.edu>
Co-authored-by: Mark Berrill <berrillma@ornl.gov>
Co-authored-by: Zhe Rex Li <zhe.rex.li@gmail.com>
Co-authored-by: Zhe Li <zzl109@gadi-login-01.gadi.nci.org.au>
Co-authored-by: Zhe Li <zzl109@gadi-login-04.gadi.nci.org.au>
Co-authored-by: Zhe Li <zzl109@gadi-login-02.gadi.nci.org.au>
Co-authored-by: Zhe Li <zzl109@gadi-login-06.gadi.nci.org.au>
Co-authored-by: Zhe Li <zzl109@gadi-login-05.gadi.nci.org.au>
2022-09-07 21:44:16 +02:00

91 lines
2.8 KiB
Python
Executable File

import numpy as np
import math
import matplotlib.pyplot as plt
#physical constant
k_B_const = 1.380649e-23 #[J/K]
N_A_const = 6.02214076e23 #[1/mol]
e_const = 1.602176634e-19 #[C]
epsilon0_const = 8.85418782e-12 #[C/V/m]
#other material property parameters
epsilonr_water = 80.4
T=310.15 #[K]
#input ion concentration
C_Na_in = 15e-3 #[mol/m^3]
C_Na_out = 145e-3 #[mol/m^3]
C_K_in = 150e-3 #[mol/m^3]
C_K_out = 4e-3 #[mol/m^3]
C_Cl_in = 10e-3 #[mol/m^3]
C_Cl_out = 110e-3 #[mol/m^3]
#calculating Debye length
#For the definition of Debye lenght in electrolyte solution, see:
#DOI:10.1016/j.cnsns.2014.03.005
#Eq(42) in Yoshida etal., Coupled LB method for simulator electrokinetic flows
prefactor= math.sqrt(epsilonr_water*epsilon0_const*k_B_const*T/2.0/N_A_const/e_const**2)
debye_length_in = prefactor*np.sqrt(np.array([1.0/C_Na_in,1.0/C_K_in,1.0/C_Cl_in]))
debye_length_out = prefactor*np.sqrt(np.array([1.0/C_Na_out,1.0/C_K_out,1.0/C_Cl_out]))
print("Debye length inside membrane in [m]")
print(debye_length_in)
print("Debye length outside membrane in [m]")
print(debye_length_out)
#setup domain
cube_length_z = 192
cube_length_xy = 64
#set LBPM domain resoluiton
h=0.01 #[um]
print("Image resolution = %.6g [um] (= %.6g [m])"%(h,h*1e-6))
domain=2*np.ones((cube_length_z,cube_length_xy,cube_length_xy),dtype=np.int8)
zgrid,ygrid,xgrid=np.meshgrid(np.arange(cube_length_z),np.arange(cube_length_xy),np.arange(cube_length_xy),indexing='ij')
domain_centre=cube_length_xy/2
make_bubble = np.logical_and(zgrid>=cube_length_z/4,zgrid<=cube_length_z*0.75)
domain[make_bubble]=1
##save domain
file_name= "Pseudo3D_double_plane_membrane_z192_xy64_InsideLabel1_OutsideLabel2.raw"
domain.tofile(file_name)
print("save file: "+file_name)
#debug plot
#plt.figure(1)
#plt.pcolormesh(domain[:,int(domain_centre),:])
#plt.colorbar()
#plt.axis("equal")
#plt.show()
##generate initial ion concentration - 3D
#domain_Na = C_Na_out*np.ones_like(domain,dtype=np.float64)
#domain_Na[make_bubble] = C_Na_in
#domain_K = C_K_out*np.ones_like(domain,dtype=np.float64)
#domain_K[make_bubble] = C_K_in
#domain_Cl = C_Cl_out*np.ones_like(domain,dtype=np.float64)
#domain_Cl[make_bubble] = C_Cl_in
#
#domain_Na.tofile("Pseudo3D_plane_membrane_concentration_Na_z192_xy64.raw")
#domain_K.tofile("Pseudo3D_plane_membrane_concentration_K_z192_xy64.raw")
#domain_Cl.tofile("Pseudo3D_plane_membrane_concentration_Cl_z192_xy64.raw")
##debug plot
#plt.figure(2)
#plt.subplot(1,3,1)
#plt.title("Na concentration")
#plt.pcolormesh(domain_Na[:,int(bubble_centre),:])
#plt.colorbar()
#plt.axis("equal")
#plt.subplot(1,3,2)
#plt.title("K concentration")
#plt.pcolormesh(domain_K[:,int(bubble_centre),:])
#plt.colorbar()
#plt.axis("equal")
#plt.subplot(1,3,3)
#plt.title("Cl concentration")
#plt.pcolormesh(domain_Cl[:,int(bubble_centre),:])
#plt.colorbar()
#plt.axis("equal")
#plt.show()