{"id":183,"date":"2022-08-08T16:46:00","date_gmt":"2022-08-08T15:46:00","guid":{"rendered":"https:\/\/sites.lesia.obspm.fr\/filippo-pantellini\/?p=183"},"modified":"2023-08-16T12:04:11","modified_gmt":"2023-08-16T11:04:11","slug":"numerical-code-to-simulate-the-interaction-of-a-stellar-wind-with-a-planetary-magnetosphere-freely-downloadable-on-this-site","status":"publish","type":"post","link":"https:\/\/sites.lesia.obspm.fr\/filippo-pantellini\/en\/2022\/08\/08\/numerical-code-to-simulate-the-interaction-of-a-stellar-wind-with-a-planetary-magnetosphere-freely-downloadable-on-this-site\/","title":{"rendered":"A numerical code to simulate the interaction of a stellar wind with a planetary magnetosphere  (downloadable on this site)"},"content":{"rendered":"<div class=\"wp-block-image\">\n<figure class=\"alignright is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/sites.lesia.obspm.fr\/filippo-pantellini\/files\/2022\/08\/planet_mag_amrvac_en.png\" alt=\"\" class=\"wp-image-350\" width=\"122\" height=\"122\" srcset=\"https:\/\/sites.lesia.obspm.fr\/filippo-pantellini\/files\/2022\/08\/planet_mag_amrvac_en.png 244w, https:\/\/sites.lesia.obspm.fr\/filippo-pantellini\/files\/2022\/08\/planet_mag_amrvac_en-150x150.png 150w\" sizes=\"auto, (max-width: 122px) 100vw, 122px\" \/><\/figure><\/div>\n\n\n<p><em>Last update: 16 August\u00a02023<\/em> (updated version of the code) <\/p>\n\n\n\n<p><a rel=\"noreferrer noopener\" aria-label=\" (s\u2019ouvre dans un nouvel onglet)\" href=\"https:\/\/drive.google.com\/file\/d\/1fTYDGYiJNwDqyupJUuL37FGLeb-KDFEP\/view?usp=sharing\" target=\"_blank\">PLANET_MAG_AMRVAC<\/a>&nbsp;is a code  which numerically simulates the interaction of a supersonic stellar wind with the magnetosphere of a magnetized planet. The code can be applied to the case of the solar wind interacting with Mercury, the Earth or with one of the giant planets of the solar system. The code is flexible and can be used to simulate the interaction of a generic stellar wind with the magnetosphere of an arbitrary exoplanet.<br><\/p>\n\n\n\n<p>Depending on the configuration, a simulation may last less than one hour on a laptop or several days on a supercomputer offering  hundreds of cores.<br><\/p>\n\n\n\n<p>The code solves the time-dependent 3D magnetohydrodynamic (MHD) equations. It can be downloaded <a rel=\"noreferrer noopener\" aria-label=\" (s\u2019ouvre dans un nouvel onglet)\" href=\"https:\/\/drive.google.com\/file\/d\/1fTYDGYiJNwDqyupJUuL37FGLeb-KDFEP\/view?usp=sharing\" target=\"_blank\">here<\/a>&nbsp;(size &lt; 1&nbsp;MB). The code is MPI-parallelized and runs on Linux (potentially also on Mac OSX).<\/p>\n\n\n\n<p>Windows users may run the code within a Linux virtual machine. Various sites explain how to install a virtual machine (see e.g. <a href=\"https:\/\/www.instructables.com\/How-to-install-Linux-on-your-Windows\/\" target=\"_blank\" rel=\"noreferrer noopener\" aria-label=\" (s\u2019ouvre dans un nouvel onglet)\">here<\/a>).<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/sites.lesia.obspm.fr\/filippo-pantellini\/files\/2022\/06\/Capture-d\u2019\u00e9cran-de-2020-01-16-14-48-18.png\" alt=\"Simulation de la magn\u00e9osph\u00e8re de Mercure avec le code PLANET_MAG_AMRVAC\" class=\"wp-image-83\" width=\"333\" height=\"255\" srcset=\"https:\/\/sites.lesia.obspm.fr\/filippo-pantellini\/files\/2022\/06\/Capture-d\u2019\u00e9cran-de-2020-01-16-14-48-18.png 959w, https:\/\/sites.lesia.obspm.fr\/filippo-pantellini\/files\/2022\/06\/Capture-d\u2019\u00e9cran-de-2020-01-16-14-48-18-300x231.png 300w, https:\/\/sites.lesia.obspm.fr\/filippo-pantellini\/files\/2022\/06\/Capture-d\u2019\u00e9cran-de-2020-01-16-14-48-18-768x590.png 768w, https:\/\/sites.lesia.obspm.fr\/filippo-pantellini\/files\/2022\/06\/Capture-d\u2019\u00e9cran-de-2020-01-16-14-48-18-150x115.png 150w, https:\/\/sites.lesia.obspm.fr\/filippo-pantellini\/files\/2022\/06\/Capture-d\u2019\u00e9cran-de-2020-01-16-14-48-18-195x150.png 195w\" sizes=\"auto, (max-width: 333px) 100vw, 333px\" \/><figcaption class=\"wp-element-caption\">Mercury&rsquo;s magnetosphere simulated with  PLANET_MAG_AMRVAC<\/figcaption><\/figure><\/div>\n\n\n<h3 class=\"wp-block-heading\" id=\"mce_0\"><strong>Installing and testing the code:<\/strong><\/h3>\n\n\n\n<p>Some software may not be installed on your Linux. Most of the time, problems during installation or execution of the code are due to missing software. So, please verify that at least the following ones are installed gfortran, mpirun, make, perl, bash, csh, sed, awk. If necessary, install the missing ones.<\/p>\n\n\n\n<p><strong>1 &#8211;<\/strong> Download the compressed folder with all the required files from  <a rel=\"noreferrer noopener\" href=\"https:\/\/drive.google.com\/file\/d\/1fTYDGYiJNwDqyupJUuL37FGLeb-KDFEP\/view?usp=sharing\" target=\"_blank\">here<\/a><\/p>\n\n\n\n<p><strong>2 &#8211;<\/strong> Expand the folder in a place of your choice on your computer (in a place where you have write access). To do so, you may open a terminal in the folder with the downloaded file and type (<strong>NB: <\/strong>adapt instruction with name of downloaded file):<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">tar zxvf planet_mag_amrvac_2023-02-29_18-42-25.tar.gz<\/pre>\n\n\n\n<p><strong>3 &#8211;<\/strong> Enter into the newly created folder and proceed to the sub-folder \/Mysimulations\/Planet_mag\/. To do so, in the terminal, type successively, e.g. :    <\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">cd .\/planet_mag_amrvac_2023-02-29_18-42-25<\/pre>\n\n\n\n<pre class=\"wp-block-preformatted\">cd .\/Mysimulations\/Planet_mag\/<\/pre>\n\n\n\n<p><strong>4 &#8211;<\/strong> In the terminal, type:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"> .\/configure<\/pre>\n\n\n\n<p><strong>5 &#8211;<\/strong> And, if no errors,  type : <\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">.\/run_new<\/pre>\n\n\n\n<p>Answer \u00ab\u00a0y\u00a0\u00bb (without quotation marks) to the question. Verify that the code compiles with  no errors. Compiling can last a few minutes.<\/p>\n\n\n\n<p><strong>NB:&nbsp;<\/strong>Errors are most offen due to one ore more missing software. If everything goes as expected you should see the following message in your terminal:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"> Finished AMRVAC in : 9.427 sec<\/pre>\n\n\n\n<p><strong>6 &#8211;<\/strong> Simulation results are stored in a sub-folder of  .\/datamr  a series of files of the type  *0000.dat, *0001.dat, &#8230; <\/p>\n\n\n\n<p><strong>NB: <\/strong>Verify that the folder with at least two files *.dat in it has effectively been created.<\/p>\n\n\n\n<p>If you passed all the above steps, the code is in principle correctly installed and working on your machine. <\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Visualizing results <\/strong><\/h3>\n\n\n\n<p>To visualize the results of your simulation, it is necessary to transform the *.dat files into a format readable by some 3D visualization software. We recommend using the VTU format for importing into the open-source software ParaView (see <a href=\"http:\/\/paraview.org\">paraview.org<\/a>) which is available for Linux, macOS and Windows platforms.<\/p>\n\n\n\n<p><strong>1 &#8211;<\/strong> To convert *.dat files to *.vtu files, go to the directory with the *.dat files (a subdirectory of .\/datamr ) and use the aiconvert script which is located in the tools subdirectory of the upper folder of the installed tree. So, for example, to convert all *0000.dat, *0001.dat, &#8230;, *0008.dat you should type:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">  ..\/..\/..\/..\/..\/tools\/aiconvert 0 8                        <\/pre>\n\n\n\n<p><strong>2 &#8211;<\/strong> To import the *.vtu files into  ParaView do the following: Start ParaView (e.g. by typing paraview in a terminal). In the ParaView upper bar select File -&gt; Open, mouse-left-click on the list of  the corresponding *.vtu files and click on OK. This will load all files at once into ParaView. <\/p>\n\n\n\n<p><strong>NB:<\/strong> The target format of the conversion is specified in the amrvac.par file on the line with convert_type=&rsquo;vtumpi&rsquo;. You may find <a href=\"http:\/\/amrvac.org\/md_doc_convert.html\">here<\/a> a list with the accepted formats.  <\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Adapt&nbsp;the&nbsp;simulation&nbsp;parameters&nbsp;to&nbsp;your&nbsp;needs<\/strong><\/h3>\n\n\n\n<p>You can modify the simulation parameters by modifying the <strong>input_parameters<\/strong> file which is located in the directory \/Mysimulations\/Planet_mag\/, ie the same one from which you launched the previous simulation. In this file you can specify the parameters of the stellar wind, the planetary parameters, the size of the simulation domain, the coarseness of the numerical grid, the duration of the simulation, etc. Most parameters should be understandable without special explanations. On each line of the file, the text after one or more # is a comment.<\/p>\n\n\n\n<p>The simulation domain corresponds to the volume enclosed by two spherical shells with the same centre and radius <strong>xprobmin1<\/strong> (inner boundary of the simulation) and <strong>xprobmax1<\/strong> (outer boundary of the simulation). The numerical grid is structured in spherical geometry (r, theta, phi) with the planet&rsquo;s centre located at r=0.<\/p>\n\n\n\n<p>The conditions at the inner boundary (at r=xprobmin1) for the  3 components of the fluid momentum (m_r_inner_boundary, m_theta_inner_boundary, m_phi_inner_boundary) can be adapted to some extent as described <a rel=\"noreferrer noopener\" aria-label=\" (s\u2019ouvre dans un nouvel onglet)\" href=\"http:\/\/amrvac.org\/md_doc_par.html#par_boundlist\" target=\"_blank\">here<\/a>. Pressure and density are user defined constant values for the whole boundary, whereas the magnetic field is defined by the user defined multipolar coefficients and magnetic axis orientation in the Planetary parameters section of the <strong>input_parameters<\/strong> file.           <\/p>\n\n\n\n<p>When satisfied with the settings in <strong>input_parameters<\/strong> just repeat steps 4 and 5 to start a new simulation.   <\/p>\n\n\n\n<p><strong>NB 1: <\/strong>The stellar wind does always flow parallel to the z-axis, towards negative z values.<\/p>\n\n\n\n<p><strong>NB 2<\/strong>: At the outer boundary, along its intersection with a cone with its vertex in r=0 and an opening angle  of 160 deg with respect to the negative z-axis,  the conditions are of the type \u00ab\u00a0free outflow\u00a0\u00bb with the radial variation equals to zero for all fields (i.e. \u2202\/\u2202r =0). On the remaining portion of the outer boundary stellar wind values are imposed.      &nbsp;<\/p>\n\n\n\n<p><strong><a rel=\"noreferrer noopener\" aria-label=\" (s\u2019ouvre dans un nouvel onglet)\" href=\"https:\/\/drive.google.com\/file\/d\/1fTYDGYiJNwDqyupJUuL37FGLeb-KDFEP\/view?usp=sharing\" target=\"_blank\">Download planet_mag_amrvac<\/a><\/strong><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Last update: 16 August\u00a02023 (updated version of the code) PLANET_MAG_AMRVAC&nbsp;is a code which numerically simulates the interaction of a supersonic stellar wind with the magnetosphere of a magnetized planet. The code can be applied to the case of the solar &hellip; <a href=\"https:\/\/sites.lesia.obspm.fr\/filippo-pantellini\/en\/2022\/08\/08\/numerical-code-to-simulate-the-interaction-of-a-stellar-wind-with-a-planetary-magnetosphere-freely-downloadable-on-this-site\/\">Continuer la lecture <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":26,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":true,"template":"","format":"standard","meta":{"footnotes":""},"categories":[6,305,299],"tags":[313],"class_list":["post-183","post","type-post","status-publish","format-standard","hentry","category-mhd","category-planetary-magnetospheres","category-solar-wind","tag-plasma-physics"],"_links":{"self":[{"href":"https:\/\/sites.lesia.obspm.fr\/filippo-pantellini\/wp-json\/wp\/v2\/posts\/183","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/sites.lesia.obspm.fr\/filippo-pantellini\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/sites.lesia.obspm.fr\/filippo-pantellini\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/sites.lesia.obspm.fr\/filippo-pantellini\/wp-json\/wp\/v2\/users\/26"}],"replies":[{"embeddable":true,"href":"https:\/\/sites.lesia.obspm.fr\/filippo-pantellini\/wp-json\/wp\/v2\/comments?post=183"}],"version-history":[{"count":50,"href":"https:\/\/sites.lesia.obspm.fr\/filippo-pantellini\/wp-json\/wp\/v2\/posts\/183\/revisions"}],"predecessor-version":[{"id":433,"href":"https:\/\/sites.lesia.obspm.fr\/filippo-pantellini\/wp-json\/wp\/v2\/posts\/183\/revisions\/433"}],"wp:attachment":[{"href":"https:\/\/sites.lesia.obspm.fr\/filippo-pantellini\/wp-json\/wp\/v2\/media?parent=183"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/sites.lesia.obspm.fr\/filippo-pantellini\/wp-json\/wp\/v2\/categories?post=183"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/sites.lesia.obspm.fr\/filippo-pantellini\/wp-json\/wp\/v2\/tags?post=183"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}