In this month’s tips and tricks video, we are going to demonstrate how you can create heterogeneous materials using images.
Click below to watch as I walk you through the process. To help you follow along, we have included the video transcription below.
There’s no reason to learn software programs through trial and error, so in addition to our tips and tricks, our upcoming training classes will support you, the COMSOL user, in utilizing best practices with many of the COMSOL modules. Please visit our training calendar and find the course that is best for you.
Create Heterogeneous Materials from Images Transcription
Welcome to Tips and Tricks video. In this video we will demonstrate how to use an image to create non-uniform materials. For our purpose, such materials are functions of spatial coordinates. An example of such material is shown on this image. Here the color scale represents relative variation of the material property. For demonstration purposes we will use very simple problem of acoustic scattering. Pressure acoustic physics is used to solve this problem.
Incident pressure field is defined in the Background Pressure Field 1 node. Here you have plane wave traveling in the X direction from the left to right. We use Perfectly Matched Boundary 1 to model open boundaries to allow pressure wave leave computation domain without back reflection. You have two materials: Material 1 is acoustic medium material defined by density rho1 and Speed of sound c1. You have Material 2 which is scattering material with different properties: density rho2 and Speed of sound c2.
Let us solve the problem. To do that you go to the study and click compute. It takes several seconds to get solution. After solution is done we see the total pressure due to scattering from the uniform object. Now we want to define non-uniform material using the image file. To do that you right-click Global Definitions > Functions and Image. Then click Browse and we find the file to import the image into the model. You click Plot and now you have image which can be used to define non-uniform material. Image is somewhat unusual but it’s OK for our demonstration purposes. Note that the scale changes from zero to one. You can assume that the scale zero corresponds to one material, scale one corresponds to material number two, and everything between is the mixture of two materials.
Now we are ready to define heterogeneous material. To do that I will add Variables 1 node on the Component 1. I read the Definitions and add Variables 1 node. Here I want to define volume fraction of the Material 1, Speed of sound of the mixture, and density of the mixture. To define those variables I read those variables from the text file. Here I have Theta which is variable for the volume fraction of Material 1 is defined as im1, which is the name of the image function. Arguments are x and y which are spatial coordinates, and then volume fraction of the second material is just 1 minus 10. Now, we have volume fraction for the first material for the second material and I can define Speed of sound of the mixture. Speed of sound of the mixture is Speed of sound of Material 1, times volume fraction of the material time of Material 1, plus Speed of sound of Material 2, times volume fraction of the Material 2. And similarly, density of the mixture is defined as density of the Material 1, times volume fraction of the Material 1, plus density of Material 2, times volume fraction of the Material 2.
We can also visualize the material properties of our domain to ensure that everything is defined as expected. To do that I add 2D Plot Group then add Surface sub-node and go to the replace Expression to plot density of the material. I go to the Material properties, find variable for the Density, and then I change color scheme to GrayScale and what we see we did retrieve original image which was used to define properties of heterogeneous domain.
That’s all for now. We have demonstrated how to use image function to define material with properties depending on the X and Y coordinates. Hope this was helpful and thank you.