Examples of Custom Physics > Schrödinger Equation Implementation > Schrodinger Equation Interface — Creating It Step by Step

Schrodinger Equation Interface — Creating It Step by Step
The following steps show how to define the Schrodinger Equation interface using the implementation defined in the previous section.
Creating the Basics
1
2
From the File menu (Windows) or the Options menu (the cross-platform version), choose Preferences. In the Preferences dialog box, select Physics Builder in the list and then select the Enable Physics Builder check box if not selected already.
3
From the File menu, choose New (). On the New page, click the Physics Builder button (). The Physics Builder window replaces the Model Builder window on the COMSOL Desktop.
4
On the Home toolbar, click Add Physics Interface () (or right-click the root node (Untitled.mphphb) and select Physics Interface).
5
Go to the Settings window for Physics Interface. In the Identifiers section:
-
In the Description field enter Schrodinger Equation. Click the Rename node using this text button () to update the node in the Physics Builder.
-
Select the Type check box and replace the default with SchrodingerEq.
-
In the Default name and tag field enter scheq.
-
If you have a custom Icon for the interface, click the Browse button to locate the icon file. The default is to use the physics.png icon ().
6
The Schrodinger Equation interface should support all space dimensions except 0D. Under Restrictions keep the defaults for the Allowed space dimensions, which already excludes 0D.
7
In the Allowed study types list, select the default study types (Stationary and Time dependent). Click the Add button () and select Eigenvalue from the Allowed study types list. Click OK.
8
In the Settings section, confirm that Domain is selected from the Top geometric entity level list. This means that the equations in the physics interface apply to the domains in the geometry, which is the case for most physics. Leave the default setting for the Default frame list as Material.
9
It is good practice to save the physics use interface after completing some steps. From the File menu, choose Save and create a physics interface file, SchrodingerEquation.mphphb in the default location. Click Save.
This concludes the initial steps to set up the structure for the physics interface. The next steps add equations, boundary conditions, and variables.
Adding Features
First declare the dependent variable Ψ:
1
Right-click the Schrodinger Equation node and from the Variables menu select Dependent Variable Declaration (). Or on the Physics Interface toolbar, click the button with the same name.
2
In the Settings window locate the Declaration section.
-
Keep the default for the Dependent variable reference list (Use physical quantity).
-
From the Physical quantity list select Dimensionless (1).
-
In the Default variable name field enter psi.
-
In the Description field enter Wave function.
-
In the Symbol (LaTeX encoded) field enter \psi (the LaTeX syntax for the Greek letter ψ).
-
Keep the default Dimension (Scalar), because Ψ is a scalar field.
3
In the Preferences section, both check boxes are selected by default. Keep these settings.
You also need to add a Dependent Variable node in the Schrödinger equation domain feature to create the shape function (element type) for the dependent variable in the domain (see Step 16 below).
Add a Schrodinger Equation Model Domain Feature
Next add the Schrödinger equation in a domain feature:
1
Right-click the Schrodinger Equation node and from the Features menu select Domain Feature ().
2
In the Settings window locate the Identifiers section.
-
In the Description field enter Schrodinger equation model. Click the Rename node using this text button () to update the node in the Physics Builder.
-
Select the Type check box and replace the default with SchrodingerEqu.
-
In the Default name and tag field enter schequ.
3
In the Restrictions section, keep the default setting (Same as parent) for the Allowed space dimensions and Allow study types lists. By selecting Customized you can restrict the feature to a subset of the allowed space dimensions or study types for the physics.
4
In the Selection Settings section, confirm that Active is displayed in the Applicable entities list. Keep the Override rule default setting (Built in), and the Override rule default (Exclusive).
5
Under Coordinate Systems, keep the default settings (Frame system) for the Input base vector system and Base vector system lists. Also keep the default Frame type as Material.
6
Under Preferences click to select the Add as default feature check box to make this the default feature for all domains.
7
Right-click the Schrodinger Equation Model node and from the Inputs menu select User Input ().
8
In the Settings window locate the Declaration section.
-
In the Input name field enter mu.
-
In the Description field enter Reduced mass.
-
In the Symbol (LaTeX encoded) field enter \mu (LaTeX syntax for the Greek letter μ).
-
From the Physical quantity list select Mass (kg).
-
Keep the default settings in the Array type (Single) and Dimension (Scalar) lists for a basic scalar quantity. Also leave the Allowed values setting to Any for an entry of a general scalar number.
-
In the Default value field enter me_const (the electron mass, which is a built-in physical constant) in the Default value field.
9
Right-click the User Input node and select Variable Definition ().
This user input then becomes available as a variable schequ.mu in, for example, the predefined expressions for results evaluation. You can also refer to mu directly in the weak equation. Keep all other default settings for this node.
10
Right-click the Schrodinger Equation Model node and from the Inputs menu select User Input ().
11
In the Settings window, locate the Declaration section.
-
In the Input name field enter V.
-
In the Description field enter Potential energy.
-
In the Symbol (LaTeX encoded) field enter V.
-
From the Physical quantity list select Energy (J).
-
Keep the default settings in the Array type (Single) and Dimension (Scalar) lists for a basic scalar quantity. Also leave the Allowed values setting to Any for an entry of a general scalar number.
-
Use the default value 0 in the Default value field.
12
Right-click the User Input 2 node and select Variable Definition ().
This user input then becomes available as a variable schequ.V in, for example, the predefined expressions for results evaluation. You can also refer to V directly in the weak equation. Keep all other default settings for this node.
13
Right-click the Schrodinger Equation Model node and from the Equations menu select Weak Form Equation (). This is where you specify the equation for the domains in the physics interface.
14
In the Settings window locate the Integrand section. In the Expression field, enter -hbar_const^2/(2*mu)*psi·test(psi)-(V-lambda)*psi·test(psi)
This expression implements the Schrödinger equation formulation for this interface. Press Ctrl+Space to get a list of the supported operations that includes any special characters. See Tensor Parser for the keyboard entries to create the del operator () and the dot product (·).
15
In the Selection section keep the default Selection setting (From parent), which means it inherits the selection from the top node. Also keep the default Output entities setting (Selected entities) to use the selected domains as the output. Keep all other defaults.
16
Right-click the Schrodinger Equation Model node and from the Variables menu select Dependent Variable Definition ().
17
In the Settings window, locate the Definition section. From the Physical quantity list select Dimensionless (1). Lagrange elements are the most widely used and are suitable for this physics interface. The default shape-function order becomes 2. Keep the other defaults.
Add a Default Zero Probability Boundary Condition
Add the default boundary condition:
1
Right-click the Schrodinger Equation (Physics Interface 1) node and from the Features menu select Boundary Condition ().
2
In the Settings window locate the Identifiers section.
-
In the Description field enter Zero probability. Click the Rename node using this text button () to update the node in the Physics Builder.
-
Select the Type check box and replace the default with ZeroProb.
-
In the Default name and tag field enter zpb.
3
Keep all the defaults for the Restrictions, Selection Settings, and Coordinate Systems sections.
4
In the Preferences section, select the Add as default feature check box. Keep the Default entity types as Exterior to make this a default condition on exterior boundaries only.
5
Right-click the Zero Probability node and from the Equations menu select Constraint ().
6
In the Settings window locate the Declaration section. Enter 0-psi in the Expression field to make Ψ = 0 on the boundary (this expression is set equal to zero by the constraint).
7
In the Shape Declaration section, from the Physical quantity list select Dimensionless (1) to declare the correct dimension for the constrained variable Ψ. Keep all other default settings.
Click the Schrodinger Equation node. On the Settings window under Default Features note that the Schrodinger Equation Model and the Zero Probability boundary condition are listed.
Add a Wave Function Value Boundary condition
Add the Wave Function Value boundary condition Ψ = Ψ0:
1
Right-click the Schrodinger Equation node and from the Features menu select Boundary Condition ().
2
In the Settings window locate the Identifiers section.
-
In the Description field enter Wave function value. Click the Rename node using this text button () to update the node in the Physics Builder.
-
Select the Type check box and replace the default with WaveFunc.
-
In the Default name and tag field enter wvfcn.
3
Keep all the defaults for the Restrictions, Selection Settings, and Coordinate Systems sections.
4
Right-click the Wave Function Value node and from the Inputs menu select User Input ().
5
In the Settings window locate the Declaration section.
-
In the Input name field enter psi0.
-
In the Description field enter Wave function value.
-
In the Symbol (LaTeX encoded) field enter \psi_0. This is for the symbol Ψ0.
-
From the Physical quantity list select Dimensionless (1).
-
Keep the default settings in the Array type (Single) and Dimension (Scalar) lists for a basic scalar quantity. Also leave the Allowed values setting to Any for an entry of a general scalar number.
-
Keep the Default value at 0.
6
Right-click the Wave Function Value node and from the Equations menu select Constraint ().
7
In the Settings window locate the Declaration section. Enter par.psi0-psi in the Expression field to make Ψ = Ψ0 on the boundary. The par prefix indicates a local parameter scope and is necessary in order to refer to a user input that is not defined as a variable.
8
In the Shape Declaration section, from the Physical quantity list select Dimensionless (1) to declare the correct dimension for the constrained variable Ψ.
This feature uses a user input that should appear in a section in the Settings window. The constraint automatically adds an extra section for enabling weak constraints and set the type of constraint, but it is necessary to specify a section for the user input.
9
Right-click the Wave Function Value node and from the Inputs menu select User Input Group ().
10
In the Settings window locate the Declaration section. In the Group name field enter WaveFunc_section and in the Description field enter Wave function.
11
Under the Group members list, click the Add button () and from the Group members list select User Input 1 (par.psi0). Click OK.
12
In the GUI Options section, from the GUI Layout list select Group members define a section. See User Input Group GUI Options for more information.
The remaining boundary condition, Axial Symmetry, appears automatically on symmetry boundaries in axisymmetric models.
Adding an Additional Variable
Add the probability density function ⏐Ψ⏐2 as a variable that is available in the model and for plotting (when the Show in plot menu check box is selected in the Preferences section, which is the default setting) or evaluating:
1
Right-click the Schrodinger Equation node and from the Variables menu select Variable Declaration ().
2
In the Settings window locate the Declaration section.
-
In the Variable name field enter probdens.
-
In the Description field enter Probability density function.
-
In the Symbol (LaTeX encoded) field enter {\mid\psi\mid}^2 to display ⏐Ψ⏐2.
-
For the Dimension list, keep the default setting (Scalar).
-
From the Physical quantity list select Dimensionless (1).
3
Keep all the default settings in the Preferences section. The Show in plot menu check box must be selected for this variable to appear as a predefined expression in plots.
4
Right-click the Variable Declaration 1 node and select Variable Definition ().
5
In the Settings window locate the Definition section. Enter abs(psi)^2 in the Expression field.
Defining Default Plots and Default Plot Quantities
Define a default 2D plot group for plotting the probability density function and make the probability density function the default scalar quantity for user-defined plots:
1
Right-click the Schrodinger Equation node and select Result Defaults ().
2
Right-click the Result Defaults 1 node and select 2D Plot Group ().
3
Right-click the 2D Plot Group 1 () node and select Surface ().
4
In the Settings window for Surface in the Description field, select the check box and enter Probability density, and then in the Expression field enter probdens.
5
Right-click the Surface 1 node and select Rename (or press F2). In the Rename Surface dialog box, in the New label field enter Probability Density. Click OK.
6
Right-click Result Defaults 1 node and select Plot Defaults ().
7
Right-click the Plot Defaults 1 node and select Default Scalar Plot ().
8
In the Settings window in the Expression field enter probdens. In the Description field enter Probability density. This makes the probability density function the default plot for all scalar plots.
Making a Quantum Mechanics Physics Area
To add the Schrodinger Equation interface to a new physics area for Quantum Mechanics under the Mathematics branch:
1
Under Definitions Library right-click Physics Areas () and select Physics Area ().
2
In the Settings window locate the Physics Area Settings section.
-
In the Name field enter QuantumMechanics.
-
In the Description field enter Quantum Mechanics.
-
The default Icon is physics.png (), which is appropriate for this physics. Otherwise, click Browse to use another icon.
-
In the Weight field enter 10 to make the Quantum Mechanics area appear last in the list under Mathematics (the higher the weight, the lower position the physics area gets in the tree of physics interfaces).
3
Under Parent Area click the Mathematics node. Click the Set as Parent button (). This moves the new physics area under the Mathematics node.
4
Click the Schrodinger Equation node. Locate the Physics Area section and click to expand it.
5
Expand the Mathematics branch and click Quantum Mechanics. Click the Set as Parent button (). This places the Schrodinger Equation interface under the Quantum Mechanics physics area.
6
This completes the definition of this Schrodinger Equation interface. Save the file that contains the physics interface.
The final node sequence in the Physics Builder tree should match this figure: