{"id":15062453,"url":"https://github.com/mario22-mnd/codigo-tfg","last_synced_at":"2026-02-02T23:47:00.441Z","repository":{"id":220648151,"uuid":"749434463","full_name":"Mario22-MND/Codigo-TFG","owner":"Mario22-MND","description":"En este repositorio se muestra el código utilizado en el TFG “Implementación de un simulador 2D de elementos finitos en Julia” que nos permite, mediante el método de elementos finítos, calcular el campo electromagnético transversal en una guia de onda rectangular cerrada.","archived":false,"fork":false,"pushed_at":"2024-02-05T15:41:05.000Z","size":1362,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-06-28T00:05:37.983Z","etag":null,"topics":["fem","julia-language","numerical-integration"],"latest_commit_sha":null,"homepage":"","language":"Julia","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Mario22-MND.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-01-28T15:23:15.000Z","updated_at":"2025-04-06T17:01:15.000Z","dependencies_parsed_at":"2024-02-05T16:50:59.314Z","dependency_job_id":"26cfb9b9-e9e0-4437-97ce-6af331d69f3b","html_url":"https://github.com/Mario22-MND/Codigo-TFG","commit_stats":null,"previous_names":["mario22-mnd/codigo-tfg"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/Mario22-MND/Codigo-TFG","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Mario22-MND%2FCodigo-TFG","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Mario22-MND%2FCodigo-TFG/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Mario22-MND%2FCodigo-TFG/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Mario22-MND%2FCodigo-TFG/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Mario22-MND","download_url":"https://codeload.github.com/Mario22-MND/Codigo-TFG/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Mario22-MND%2FCodigo-TFG/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":262352621,"owners_count":23297689,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["fem","julia-language","numerical-integration"],"created_at":"2024-09-24T23:37:46.479Z","updated_at":"2026-02-02T23:47:00.374Z","avatar_url":"https://github.com/Mario22-MND.png","language":"Julia","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Code for 2D finite element simulator in Julia\n\nThis repository shows the code created to build a 2D finite element simulator in Julia. The most important information about the code will be documented below.\n\n# Table of Contents\n\n- [Installation](#installation)\n- [Use](#use)\n- [Future expansions](#futureExpansions)\n\n# Installation\nIn order to use the code you must install several Julia packages and import the Gmsh API. The packages or libraries to install are: \n- LinearAlgebra: To obtain the eigenvalues and eigenvectors of the mass and stiffness matrix.\n- SimplexQuad (https://github.com/eschnett/SimplexQuad.jl): allows us to obtain the integration points and the pessos according to the Gauss-Radau quadrature.\n- Plots: to represent the meshes as well as the final results.\n- LaTeXStrings: to mathematically customize our plots.\n\n## Gmsh API\nIn order to use the Gmsh API we need the dynamic library Gmsh and the Julia module ('gmsh.jl'). This is obtained from the binary software development kit (SDK) available from the Gmsh website (https://gmsh.info/bin/), for Windows, Linux, and macOS. By downloading and unzipping the gmsh*-sdk.* file corresponding to your operating system and adding the directory (lib) directory of the SDK to JULIA_LOAD_PATH.  Once we have downloaded and unzipped the SDK, we look for the /.julia/config folder.\nIn case it does not exist, we will have to create it. Once the folder is created, create or edit the startup.jl file as follows:\n\n```Julia\n # We save the path to the file we want to load in\nJULIA_LOAD_PAD push !( LOAD_PATH , \"/path/to/file \")\n```\n\nThis startup.jl file is used to make custom configurations and load specific packages or modules that you want to be available every time you start Julia. The last step is to restart Julia.\n\n\n# Use\nThe code consists of a series of modules, where the main one is called \"Numerical_integration_v1.jl\". This is responsible for calling \"Mesh_object.jl\" which in turn calls all the others. The dependencies of the modules are shown in the following image:\n\n![dependencias_código](https://github.com/Mario22-MND/Codigo-TFG/assets/126000794/2b5e0d2e-07d6-4e69-8abd-a097c1722f26)\n\nWhere the arrows show from whom the information is obtained or on whom it depends.\n\n## Rect_waveguide_triangles/quads.jl \nThese two code snippets use the Gmsh API in Julia for the creation of the object to be used. From them we get important information such as nodes, node coordinates, physical groups (boundary conditions), etc.\n\n## Elements.jl\nThis module is used to store the different types of elements. Both triangles and quads have been implemented. However, the orientation of quads has not been done, which is pending for future work. In this module \"Elements_order.jl\" is called where the order of the elements is stored transforming it to a readable format from the internal Gmsh codes shown in this web page: https://docs.juliahub.com/GmshTools/9rYp5/0.4.2/element_types/ .\n\n## Material.jl\nThanks to this module, the different materials of which the mesh is composed can be saved. It will be useful for future work where generic meshes are analyzed. For the moment it has no influence on the code.\n\n## Boundary_cond.jl\nIn this module we store the boundary conditions present in the mesh as well as all the nodes that suffer it. This module is used to check which nodes of the element have a certain boundary condition.\n\n## Mesh_object.jl\nHere you get all the important information to assemble the mesh. The elements are created where the boundary conditions are taken into account, the degrees of freedom are assigned, ect. The materials of which the mesh is composed are also saved as well as all the coordinates of the nodes that compose it.\n\nAll this information will be necessary to perform the calculations in \"Numerical_integration_v1.jl\".\n\n### Mesh_plot.jl\nIn this module a graph of the assembled mesh is created using all the information created and obtained in \"Mesh_object.jl\". Examples of some meshes, of order 1 and order 2, are shown below:\n\n![triangular_mesh_order_1_boundary_1](https://github.com/Mario22-MND/Codigo-TFG/assets/126000794/4d66a5eb-a339-4931-8c25-b615d9f5d46b)\n\n![triangular_mesh_order_2_boundary_1](https://github.com/Mario22-MND/Codigo-TFG/assets/126000794/2c6c1603-00d9-4976-86e7-a3ff2871cfb7)\n\n## Numerical_integration_v1.jl\nThis is the main module, since it is where all the calculations are performed with the information obtained so far and where the final results are obtained. It calculates the mass and stiffness matrices used to obtain the eigenvalues. You can choose by means of the attribute 'FEM_TE' if you want to calculate TE modes or TM modes. \n\nWith the obtained eigenvalues, we calculate the relative error, which decreases as we increase the order of the elements and we make the mesh finer with the 'tm' attribute of the \"Rect_waveguide_triangles.jl\" module. We must take into account two points when calculating the relative error depending on whether we calculate TE or TM modes:\n- TE modes: the first value obtained in 'k_c_fem' is used as reference, the second is the one corresponding to TE_10 mode.\n  ![resultado_modos_TE](https://github.com/Mario22-MND/Codigo-TFG/assets/126000794/b73a9988-cc92-4e41-baee-d568cc5c5d65)\n\n- TM modes: there are no TM_10 or TM_01 modes, so the first value obtained in 'k_c_fem' is the one corresponding to TM_11 mode.\n  ![resultado_modos_TM](https://github.com/Mario22-MND/Codigo-TFG/assets/126000794/eaf11dc1-6092-47f8-9fae-81f0b001d839)\n\n### Plot_results.jl\nThis module is used to plot the results and perform checks on them. Here we have checked that the error convergence rate is O(h^2p).\n\n![Mode_TE](https://github.com/Mario22-MND/Codigo-TFG/assets/126000794/159bb6d6-a2c8-4664-ac10-9a783ff31b60)\n\n![Mode_TM](https://github.com/Mario22-MND/Codigo-TFG/assets/126000794/b3a7919a-edba-4cfd-aba0-0469e59ad6ed)\n\n# Future Expansions\nThe code can be extended by implementing the parts of the code dedicated to quadrilaterals, as well as implementing the use of materials to solve generic guides.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmario22-mnd%2Fcodigo-tfg","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmario22-mnd%2Fcodigo-tfg","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmario22-mnd%2Fcodigo-tfg/lists"}