Last active
July 30, 2024 14:10
-
-
Save ismaeldamiao/b8b026203bfa896a142529f2a533d0f1 to your computer and use it in GitHub Desktop.
Solution of problem 5.2 of Simon, The Oxford Solid State Basics
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env gnuplot | |
| # MIT License | |
| # | |
| # Copyright (c) 2024 I.F.F. dos SANTOS | |
| # | |
| # Permission is hereby granted, free of charge, to any person obtaining a copy | |
| # of this software and associated documentation files (the “Software”), to | |
| # deal in the Software without restriction, including without limitation the | |
| # rights to use, copy, modify, merge, publish, distribute, sublicense, and/or | |
| # sell copies of the Software, and to permit persons to whom the Software is | |
| # furnished to do so, subject to the following conditions: | |
| # | |
| # The above copyright notice and this permission notice shall be included in | |
| # all copies or substantial portions of the Software. | |
| # | |
| # THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | |
| # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | |
| # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | |
| # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | |
| # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING | |
| # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS | |
| # IN THE SOFTWARE. | |
| set term png size 720, 720 enhanced font "serif,12" | |
| set output "simon-2_5.png" | |
| set key box | |
| set grid | |
| set xrange [1:21] | |
| set xlabel "Atomic number (Z)" | |
| set ylabel "First Ionization energy [eV]" | |
| plot \ | |
| "simon-2_5.dat" u 1:2 w p lt rgb "blue" pt 5 ps 2 title "Approximation a", \ | |
| "simon-2_5.dat" u 1:3 w p lt rgb "red" pt 7 ps 2 title "Approximation b" | |
| exit |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* ***************************************************************************** | |
| MIT License | |
| Copyright (c) 2024 I.F.F. dos SANTOS | |
| Permission is hereby granted, free of charge, to any person obtaining a copy | |
| of this software and associated documentation files (the “Software”), to | |
| deal in the Software without restriction, including without limitation the | |
| rights to use, copy, modify, merge, publish, distribute, sublicense, and/or | |
| sell copies of the Software, and to permit persons to whom the Software is | |
| furnished to do so, subject to the following conditions: | |
| The above copyright notice and this permission notice shall be included in | |
| all copies or substantial portions of the Software. | |
| THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | |
| IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | |
| FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | |
| AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | |
| LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING | |
| FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS | |
| IN THE SOFTWARE. | |
| ***************************************************************************** */ | |
| #include <stdio.h> | |
| /* *** | |
| Program to plot the graph requested by the problem 2.5 of Simon, | |
| The Oxford Solid State Basics. | |
| COMPILE: | |
| cc simon-2_5.c -o simon-2_5 | |
| *** */ | |
| #define Rydberg_energy 13.605693122990 // eV | |
| int main(void){ | |
| /* Note that: | |
| n is the Principal quantum number */ | |
| int Z_nuc, N_inside, N_same, n; | |
| double Z, E, tmp; | |
| FILE *data; | |
| data = fopen("simon-2_5.dat", "w"); | |
| if(data == NULL){ | |
| fputs("Error: can't write data in a file.", stderr); | |
| return 1; | |
| } | |
| Z_nuc = 1; | |
| while(Z_nuc < 22){ | |
| if(Z_nuc < 3){ | |
| /* Shells: 1s1 -- 1s2*/ | |
| n = 1; | |
| N_inside = 0; | |
| N_same = ((Z_nuc == 1) ? 1 : (N_same + 1.0)); | |
| }else if(Z_nuc < 11){ | |
| /* Shells: 2s1 -- 2p6*/ | |
| n = 2; | |
| N_inside = 2; | |
| N_same = ((Z_nuc == 3) ? 1 : (N_same + 1.0)); | |
| }else if((Z_nuc < 19) || (Z_nuc == 21)){ | |
| /* Shells: 3s1 -- 3d1*/ | |
| n = 3; | |
| N_inside = 10; | |
| N_same = ((Z_nuc == 11) ? 1 : ((Z_nuc == 21) ? 19 : (N_same + 1.0))); | |
| }else{ | |
| /* Shells: 4s1 -- 4s2*/ | |
| n = 4; | |
| N_inside = 18; | |
| N_same = ((Z_nuc == 19) ? 1 : (N_same + 1.0)); | |
| } | |
| /* Approximation a */ | |
| Z = (double)(Z_nuc - N_inside); | |
| tmp = (double)(n*n); | |
| E = Rydberg_energy * Z*Z / tmp; | |
| fprintf(data, "%d %g ", Z_nuc, E); | |
| /* Approximation b */ | |
| Z -= 0.5 * (double)(N_same - 1); | |
| E = Rydberg_energy * Z*Z / tmp; | |
| fprintf(data, "%g\n", E); | |
| ++Z_nuc; | |
| } | |
| fclose(data); | |
| return 0; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment