Basic workflow

  • Start Comsol using command ” comsol “
  • Follow:  Model Wizard → 2D →  Radio Frequency / Electromagnetic Waves, Frequency Domain (emw) → Add
  • You can either press ‘Done’ at this step and choose your study later, or you can move to Study Selection if you already know what study you will be using.

For the rest of this document, you don’t have to follow it completely, these are just suggested guidelines to facilitate your experience with Comsol.

  • Define your parameters in Global Definitions → Parameters:
    It is always a good practice to use parameters, so that you will be able to easily modify whole simulation environment if you need to.
  • Build your geometry. You can create any geometrical entity by right clicking geometry and choosing what is needed.
    Hints: You can use duplication (Ctrl+Shift+D) of your entities or you can create ‘Layers’ instead of multiple entities.
  • Define materials to be used: right-click ‘Materials’ and choose ‘Blank Material’. Then you can assign material information to the domains.
    • Here, for the Material Contents, Comsol will be asking permittivity and permeability information by default. You can change that simply by following: ‘Electromagnetic Waves → Wave Equation → Electric Displacement Field → Electric Displacement Field Model → choose: Refractive Index’. Then, when you go back to the Materials section, Comsol now asks real and imaginary parts of the refractive index.
    • If you don’t know the index of the material at the frequency you are using, you can check it here:
  • The settings in the physics section (Electromagnetic Waves) might be slightly complicated and also not so straightforwards since it depends on the simulation you want to perform. Here are some basics:
    • In this section, the boundary conditions, the sources and the ports will be defined. 
    • By default, Perfect Electric Conductor (PEC) condition is assigned to all the outer boundaries. You can leave them as they are if you think those boundaries need to be PEC, i.e., electrically reflecting.
    • You can assign Scattering (Absorbing) Boundaries to simulate open (infinite) structures. (meaning: if you don’t expect reflections from there) 
      Right-click Electromagnetic Waves, choose Scattering Boundary Condition, then choose boundaries to assign this absorbing property.
    • If you need point sources as we had in the first two exercises, you can do: right-click Electromagnetic Waves, choose Points → Line Current (out-of-plane), choose point to assign.
    • If you’d like to assign metallic/perfectly reflecting boundary within the domain: Right-click Electromagnetic Waves, choose Perfect Electric Conductor Boundary Condition, choose boundaries to assign this property. (It is not possible to assign the PEC condition that comes default for the boundaries within domain.)
    • Ports
      • These are important.
      • Very often used for photonic components to launch/absorb certain ‘photonic modes’.
      • Right-click Electromagnetic Waves, choose Port, choose boundaries to assign this property.
        • Type of the Port: Usually numeric. But then you will need ‘Boundary Mode Analysis’ in the study section.
        • Wave excitation: Generally ‘On’ for the input ports, ‘Off’ for the output ports.
  • Mesh
    • Many different ways to implement. Here is our suggestion:
    • Right-click mesh, choose Free Triangular. (so Comsol knows that we want triangles)
      • Change Geometric Entity Level to ‘Entire Geometry’ (so Comsol knows, we want them everywhere)
    • Right-click Free Triangular, choose Size.
    • Go to this ‘Size’ that sits within Free Triangular.
      • Change Geometric Entity Level to be Domain or Boundary (depends where you want to assign this Size parameters)
      • Choose respective geometric entities from the graphics view.
      • Element Size: Custom
      • Element Size Parameters: Maximum Element Size: 
        • For each wavelength within the material, at least 2 triangles should exist
        • Wavelength in material: wavelength in vacuum / real (material index)
        • For important parts, for each wavelength in the material, 6-10 triangles should exist
        • To sum up, suggested Maximum Element Size: wavelength/realPartOfRefractiveIndex/k, and k is between 2-10 depending on importance of the location.
    • You can create other ‘Size’ options within the Free Triangular to assign Size properties for other domains..
  • Study
    • We will be doing frequency domain simulations during this course.
    • So the Frequency Domain should always be there. You can add it from right-clicking Study →  Study Steps → Frequency Domain → Frequency Domain.
      • If you don’t see the Study section to right click. You can find ‘Add Study’ somewhere on the top of the window or you can right click to your very top model file. (it is probably named as ‘untitled.mph’, on the left model builder)
      • Assign frequency for the simulation in Frequency Domain Study step.
    • If you have ‘Ports’ in the physics section, and if type of those ports are set to be ‘numeric’, then you have to also assign ‘Boundary Mode Analysis’ study step for each port.
      • Right-click Study →  Study Steps → Other → Boundary Mode Analysis
      • This step has to be evaluated before the ‘Frequency Domain’. So if needed, right click and Move up.
      • Port Name should match (if you go back to Port in the Physics part, then you will see there is also a section called Port Name) Comsol matches port properties through these port names.
      • The frequency should be the same as the frequency used in the Frequency Domain Study Step.
      • Desired number of modes: This property decides how many modes to be solved for the respective port. 
      • If the excitation is on, then Comsol will launch these modes into the structure, and if it is off, then it will absorb these modes. 
      • Search Modes Around: This is the effective index guess for the modes. We usually set this value to be the real part of the refractive index of the material that we expect mode to propagate. 
      • Mode search method: Usually closes in absolute value. If you have trouble finding the modes that you wish for, then you can try other options.
    • Parameteric Sweep
      • This step is to sweep one of the parameters. This will simply act like a for-loop to perform the same simulation by changing one of the parameters defined in the environment.
      • Right-click Study → Parametric Sweep
      • This should be the top-most study. You can right-click and move it up if needed.
      • After you create it, you can simply add a parameter to sweep and add a range for the sweep operation.
      • Equivalently, you can add multiple parameters to sweep. (nested for-loops) Or you can add more than one Parametric Sweep Step.
  • Compute!
    • After setting up all of the above, it is now time to compute.
    • If there is any error, it is likely that it will prompt as soon as you hit the Compute button.
    • Make sure, material properties are assigned for all the domains, all the domains are meshed, boundary conditions are assigned properly. These three are the common errors.
    • If the error persists: 
      • Check the steps above again.
      • Check the other page: ‘Common Errors in Comsol’
      • Post a comment / Send us an email
  • Results
    • Depending on the type of the simulation, Comsol will show some results by default.
    • You can add new 2D or 1D plots by simply right-clicking Results and choosed 2D/1D Plot Group.
    • Make sure the correct data set is chosen to plot. Data sets are simply the sets created after computation. Comsol also stores previous solutions. 
      • After you add the group, then you can right click and choose what kind of graph you would like to plot.
      • For 1D:
        • Line Graph is used to plot some quantity on a given line. You will be able to choose the line that you want the plot then you can change the expression to plot.
        • Table Graph is used to plot a table that was created. It is useful when you have parametric sweeps.
      • For 2D:
        • Surface plots: You can directly change the expression by typing or replacing.
          • For example to plot z-component of the E field, you can simply type ’emw.Ez’ or You can click ‘Replace Expression’ → Electromagnetic Waves → Electric → Electric Field → choose what to plot.
        • Contour plots: They look nice as well. Simply contour plots.
        • Arrow Surface: Nice way to visualize 2D vectoral quantities.
    • There are other ways to visualize depending on the structure and type of the simulation. It is hard to mention all, but we will be covering as much as we could during the lectures. And it is strongly recommended to check them and try them. They are also fun!

This page covers the basic workflow in Comsol for the purposes of our P&S, and will be continuously updated. 

For all your comments / suggestions please contact us.


Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.