A small code that explains the docker installation, running, and visualization of the PRISMS-PF microgalvanic corrosion application.
For this demo, we're going to use Docker to grab an image of PRISMS-PF v2.4.0 and run two of our pre-built applications: allenCahn and corrosion_microgalvanic.
If you want a brief explanation about what Docker is and why we use it, go here. NOTE: The documentation for PRISMS-PF 3.0 is being redone.
To begin, please install Docker to your machine. You can find instructions for installing Docker on the official Docker website. In addition, you will need VisIt for visualization, which can be obtained from the VisIt website.
For example type
mkdir ~/DockerWorkspace
and go to that directory by
cd ~/DockerWorkspace
Download the docker image with
docker pull prismspf/prismspf:2.4
This shouldn't take too long since the compressed size in only ~1.8 GB.
Now, clone the PRISMS-PF v2.4.0 repo and its submodules.
git clone --recurse-submodules https://github.com/UMThorntonGroup/ipam-hackathon.git
NOTE: If you have a git version prior to 2.13, use --recursive instead of --recurse-submodules.
For this next part, we're going to run an interactive container.
First, go to the ipam-hackathon directory
cd ipam-hackathon
Then launch the container with one of the following commands
Linux & macOS (bash and z-shell)
docker run -ti -v $(pwd)/prisms-pf-2.4/applications:/home/dealii/phaseField/applications prismspf/prismspf:2.4
macOS (c-shell)
docker run -ti -v `pwd`/prisms-pf-2.4/applications:/home/dealii/phaseField/applications prismspf/prismspf:2.4
Windows PowerShell
docker run -ti -v ${PWD}/prisms-pf-2.4/applications:/home/dealii/phaseField/applications prismspf/prismspf:2.4
Windows Command Prompt
docker run -ti -v %cd%/prisms-pf-2.4/applications:/home/dealii/phaseField/applications prismspf/prismspf:2.4
This will link your local applications directory (the one in prisms-pf-2.4) to the one in the Docker image. If you plan to modify the core library, you should link one directory higher to preserve your changes.
The Allen-Cahn equation simulates the evolution of nonconserved order parameter (or multiple order parameters). We use this as a simple test to make sure everything is working and get you started.
Click on the copy icon on the right of each line, and paste into the terminal window (and hit return). You can ignore the warnings.
cd applications/allenCahn
cmake .
make release
./main
After the run is complete, check to see the output files have been created.
ls
You should see files named "solution-xxxx.vtu" (xxxx is a number) if all worked. These files have the snapshots of data (including the order parameter) from the simulation. We will visualize the results later.
Once you've verified everything return to the main folder.
cd ../..
Two of the many applications in PRISMS-PF simulate corrosion. One simulates microgalvanic corrosion, in which two phases of an alloy are in contact. The details can be found in the PDF document in the corrosion_microgalvanic folder (see below) and in the following publication.
Goel, V., Lyu, Y., DeWitt, S. et al. Simulating microgalvanic corrosion in alloys using the PRISMS phase-field framework. MRS Communications 12, 1050–1059 (2022). https://doi.org/10.1557/s43579-022-00266-6
To run the corrosion_microgalvanic application, you can use the following commands
cd applications/corrosion_microgalvanic
cmake .
make release
./main
This simulation will likely take a while, so we will move onto visualization while this is running.
Once your simulation is done you can exit the interactive docker container with
exit
Open a new terminal window (leaving the one with the simulation running).
Open VisIt. Select "Open" under the Sources section.
Navigate to the folder with your simulation results (which should be ~/DockerWorkspace/ipam-hackathon/prisms-pf-2.4/applications/allenCahn) and click on the solution files and press OK.
Under Plots, select Add, pseudocolor, n to plot the order parameter.
Click on Draw. This will show the two phase "microstructure". You can use the right arrow to see the evolution of the system, and the left arrow to go backwards in simulation time.
The default setting can look ugly, but there are setting that could be adjusted to make it look better (see below). If you are interested, please let me know and I'll try to help. (Generally, reduce the font size in "Annotations" under the "Controls" menu at the top toolbar.)
First quit VisIt, and restart another session. This will clear out any setting that was used for the previous plots.
Select "Open" under the Sources section.
Navigate the folder with your simulation results (which should be ~/DockerWorkspace/ipam-hackathon/prisms-pf-2.4/applications/corrosion_microgalvanic) and click on the solution files and press OK.
Here, the plot is a little more complicated, so we prepared a script for you. First we're going to copy the script to the corrosion_microgalvanic applications.
Linux/macOS
cp load_plots.py prisms-pf-2.4/applications/corrosion_microgalvanic
Windows Powershell
Copy-Item -Path "load_plots.py" -Destination "prisms-pf-2.4\applications\corrosion_microgalvanic"
Windows Command Prompt
copy load_plots.py prisms-pf-2.4\applications\corrosion_microgalvanic
To use the script, launch the CLI:
To source the load_plots.py file, paste the following command in the newly opened CLI terminal window:
Linux/macOS/Windows
Source("DockerWorkspace/ipam-hackathon/prisms-pf-2.4/applications/corrosion_microgalvanic/load_plots.py")
If this does not work (meaning it cannot find the python script where you specified), you need to do "pwd" within the corrosion_microgalvanic folder and use the abosolute path, instead of "DockerWorkspace/ipam-hackathon/prisms-pf-2.4/applications/corrosion_microgalvanic/" before load_plots.py.
If all works, you should see something like this
Again, the right arrow will advance the figure in time. You should see the surfaces receding due to corrosion in this case.
You can learn more about PRISMS-PF at the PRISMS-PF website.
There are also other tools develoed within the PRISMS Center; see the PRISMS Center Software website.