Are you sure you want to delete this task? Once this task is deleted, it cannot be recovered.
Renyuan Zhang 0910a53e6c | 9 months ago | |
---|---|---|
.. | ||
docs | 2 years ago | |
src | 3 months ago | |
README.md | 3 months ago | |
README_CN.md | 3 months ago | |
__init__.py | 3 months ago | |
solve.py | 3 months ago |
The Maxwell's equations in frequency domain is an elliptic partial differential equation describing electromagnetic waves. Its basic form is as follows:
$$(\nabla^2 + k^2)u=0$$
where $k=\omega c$ indicates the wavenumber, $\omega$ indicates the frequency and $c$ indicates the light speed.
The overall network architecture for AI to solve the Maxwell's equations in frequency domain is as follows:
Taking the two-dimensional Maxwell's equations in frequency domain as an example, the network input is $\Omega=(x, y)\in [0,1]^2$, and the network output is the PDE solution $u(x, y)$. The training loss function of the network can be constructed based on the network output and the automatic differentiation ability of the MindSpore framework. The loss function consists of PDE and BC parts:
$$L_{pde}= \dfrac{1}{N_1}\sum_{i=1}^{N_1} ||(\nabla^2 + k^2)u(x_i, y_i)||^2$$
$$L_{bc} = \dfrac{1}{N_2}\sum_{i=1}^{N_2} ||u(x_i, y_i)||^2$$
In order to ensure the uniqueness of the solution of the above equations, the boundary condition is $u_{|\partial \Omega}=\sin(kx)$. You can customize the constant wavenumber $k$. In this case, the value is $k=2$.
AI uses self-supervised training to solve the Maxwell's equations in frequency domain. Data sets are generated in real time during the running. The training and inference data generation modes are as follows:
.
└─FrequencyDomainMaxwell
├─README.md
├─docs # schematic diagram of README
├─src
├──callback.py # callback function
├──config.py # parameter configuration
├──dataset.py # dataset
├──model.py # network structure
├──solve.py # train and test
You can set training parameters and sampling parameters in src/config.py
.
Helmholtz2D_config = ed({
"name": "Helmholtz2D", # PDE name
"columns_list": ["input", "label"], # Evaluation Dataset Name
"epochs": 10, # training epochs
"batch_size": 128, # batch size
"lr": 0.001, # learning rate
"coord_min": [0.0, 0.0], # lower bound of the domain
"coord_max": [1.0, 1.0], # upper bound of the domain
"axis_size": 101, # grid resolution
"wave_number": 2 # wavenumber
})
rectangle_sampling_config = ed({
'domain' : ed({ # Defining the domain sampling
'random_sampling' : False, # random sampling or not
'size' : [100, 100], # Grid resolution without random sampling
}),
'BC' : ed({ # Defining the boundary sampling
'random_sampling' : True, # random sampling or not
'size' : 128, # batch size
'with_normal' : False, # return normal direction or not
})
})
You can use the solve.py script to train and solve the Maxwell's equations in frequency domain. During the training, the model parameters are automatically saved as a checkpoint file.
python solve.py
The loss values are displayed in real time during training:
epoch: 1 step: 79, loss is 630.0
epoch time: 26461.205 ms, per step time: 334.952 ms
epoch: 2 step: 79, loss is 196.4
epoch time: 278.594 ms, per step time: 3.527 ms
epoch: 3 step: 79, loss is 191.4
================================Start Evaluation================================
Total prediction time: 10.388108491897583 s
l2_error: 0.1875916075312643
=================================End Evaluation=================================
epoch time: 10678.531 ms, per step time: 135.171 ms
epoch: 4 step: 79, loss is 3.998
epoch time: 277.924 ms, per step time: 3.518 ms
epoch: 5 step: 79, loss is 3.082
epoch time: 274.681 ms, per step time: 3.477 ms
epoch: 6 step: 79, loss is 2.469
================================Start Evaluation================================
Total prediction time: 0.009278535842895508 s
l2_error: 0.019952444820775538
=================================End Evaluation=================================
epoch time: 292.866 ms, per step time: 3.707 ms
epoch: 7 step: 79, loss is 1.934
epoch time: 275.578 ms, per step time: 3.488 ms
epoch: 8 step: 79, loss is 2.162
epoch time: 274.334 ms, per step time: 3.473 ms
epoch: 9 step: 79, loss is 1.744
================================Start Evaluation================================
Total prediction time: 0.0029311180114746094 s
l2_error: 0.017332553759497542
=================================End Evaluation=================================
epoch time: 277.262 ms, per step time: 3.510 ms
epoch: 10 step: 79, loss is 1.502
epoch time: 272.946 ms, per step time: 3.455 ms
l2 error: 0.0173325538
per step time: 3.4550081325
The seed in the create_dataset function is set in dataset.py, and the random seed in train.py is also used.
Visit the official website home page.
MindScience is scientific computing kits for various industries based on the converged MindSpore framework.
Jupyter Notebook Python Unity3D Asset Pickle nesC other
Dear OpenI User
Thank you for your continuous support to the Openl Qizhi Community AI Collaboration Platform. In order to protect your usage rights and ensure network security, we updated the Openl Qizhi Community AI Collaboration Platform Usage Agreement in January 2024. The updated agreement specifies that users are prohibited from using intranet penetration tools. After you click "Agree and continue", you can continue to use our services. Thank you for your cooperation and understanding.
For more agreement content, please refer to the《Openl Qizhi Community AI Collaboration Platform Usage Agreement》