Commit 5d8c6676 authored by Francesco Montanari's avatar Francesco Montanari

Initial commit

parents
# Compiled
*.elc
# Packaging
.cask
# Backup files
*~
# Undo-tree save-files
*.~undo-tree
# Docs temporarily exported
docs/README.txt
docs/README.html
\ No newline at end of file
This diff is collapsed.
_____________________
COSMO.EL
Francesco Montanari
_____________________
Table of Contents
_________________
1 Description
2 Download
3 Installation
4 Usage
5 Support
6 Contributing
cosmo.el --- Cosmological Calculator
Copyright (C) 2017 Francesco Montanari
This program is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation, either version 3 of the License, or (at your
option) any later version.
This program is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License along
with this program. If not, see [http://www.gnu.org/licenses/].
1 Description
=============
This package provides a cosmological calculator integrated into the
Emacs text editor.
Cosmological quantities are computed for a Lambda-CDM model. Such a
framework describes a homogeneous and isotropic universe containing a
cosmological constant (Lambda) and a Cold Dark Matter (CDM) component,
besides ordinary species. The model is characterized by the following
parameters:
H_0: Hubble parameter (expansion rate) today
Omega_m0: Fractional matter density parameter today.
Omega_Lambda: Cosmological constant density parameter. At the moment we
consider only flat Lambda-CDM models, for which
`Omega_Lambda = 1 - Omega_m0'.
All cosmological quantities are computed at a given redshift value:
redshift: Gravitational redshift of photons frequency due to the
expansion of the Universe.
2 Download
==========
The source code can be downloaded from the [git repository page].
Alternatively, the git repository can be cloned:
,----
| git clone git@gitlab.com:montanari/cosmo-el.git
`----
[git repository page] https://gitlab.com/montanari/cosmo-el
3 Installation
==============
Copy the `cosmo-el' file into your Emacs configuration
directory. E.g., on GNU systems:
,----
| mkdir ~/.emacs.d/cosmo-el
| cp cosmo.el ~/.emacs.d/cosmo-el
`----
Open your Emacs configuration file (e.g., `~\/.emacs' on GNU systems),
and add the following lines:
,----
| ;; Cosmological calculator
| (add-to-list 'load-path "~/.emacs.d/cosmo-el/")
| (require 'cosmo)
`----
4 Usage
=======
Open Emacs and type `M-x cosmo-command', where the `command' name
varies depending on the desired computation. For example:
cosmo-set-params: Set cosmological parameters.
cosmo-calculator: Compute cosmology and display summary table in a new
buffer. The following illustrates a possible output:
,----
| Cosmology calculator.
|
| Input Parameters
| ----------------
| - Redshift: 0.1
| - Hubble constant, now [km/s/Mpc]: 70
| - Matter fractional density, now: 0.3
| <...>
|
| Cosmography at required redshift
| -------------------------------
| - Hubble parameter [km/s/Mpc]: 73.39325582095401
| <...>
`----
A complete list of interactive commands can be obtained by typing `M-x
cosmo- TAB'. Documentation is available through `C-h f cosmo-command',
where `command' should be adapted to the particular command.
5 Support
=========
Bugs and issues are tracked through the [git repository page]. Please
see [this page] about how to report bugs effectively.
[git repository page] https://gitlab.com/montanari/cosmo-el
[this page] http://www.chiark.greenend.org.uk/~sgtatham/bugs.html
6 Contributing
==============
/The project is still at an early stage/. Recommendations (and
contributions) aimed to improve the source code are highly
appreciated. New feature suggestions are also welcome, but at this
point priority will be given to reach an idiomatic and extensible
code.
Contributions can be submitted as patches. See [this page] for an
example of good patches contributions.
More substantial contributions should proceed through git
[Integration-Manager Workflow]. See [this page] for an example of a
complete working session.
[this page] http://orgmode.org/worg/org-contribute.html#patches
[Integration-Manager Workflow]
https://git-scm.com/book/en/v2/Distributed-Git-Distributed-Workflows
[this page]
https://www.gnu.org/software/gnuastro/manual/html_node/Contributing-to-Gnuastro.html
;;; cosmo.el --- Cosmological Calculator
;;
;; Copyright (C) 2017 Francesco Montanari
;;
;;
;; Author: Francesco Montanari <fmnt@fmnt.info>
;; Created: 22 April 2017
(defconst cosmo:version "0.1") ;; Version:
;; Keywords: tools
;; Homepage: http://fmnt.info/software/cosmo_el.html
;;
;; This file is not part of GNU Emacs.
;;
;; This program is free software: you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation, either version 3 of the License, or
;; (at your option) any later version.
;;
;; This program is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;;
;; You should have received a copy of the GNU General Public License
;; along with this program. If not, see <http://www.gnu.org/licenses/>.
(require 'subr-x)
;; Define in this table all independent cosmological parameters
(defconst cosmo--params (make-hash-table :test 'equal)
"Table containing LCDM cosmological parameters")
;; For flat LCDM olambda is a derived parameter
(defconst cosmo--olambda 0.7
"Cosmological constant density parameter.")
(defun cosmo-set-default ()
(interactive)
"Set cosmological parameters table to default values"
(clrhash cosmo--params)
(puthash "H0 [Km/s/Mpc]" 70.0 cosmo--params) ; Hubble today km/s/Mpc
(puthash "omatter" 0.3 cosmo--params) ; Matter today
)
(defun cosmo--read-param (name)
"Read parameter from minibuffer and convert it to number."
(string-to-number (read-from-minibuffer (format "Enter %s: " name))))
(defun cosmo--set-olambda ()
"Set the cosmological constant density parameter for flat LCDM."
(setq cosmo--olambda (- 1.0 (gethash "omatter" cosmo--params))))
(defun cosmo--check-param (name value)
"Check the validity of a cosmological parameter value."
(cond ((string= name "omatter")
(unless (and (> value 0.0) (< value 1.0))
(error "Error: omatter must be positive and less than 1")))))
(defun cosmo--put-param (name)
"Read parameter from minibuffer and add it to the parameter table."
(puthash name (cosmo--read-param name) cosmo--params))
(defun cosmo-set-params ()
"Set cosmological parameters."
(interactive)
(let ((params (hash-table-keys cosmo--params)))
(dolist (param params)
(cosmo--put-param param)
(cosmo--check-param param (gethash param cosmo--params)))))
(defun cosmo--get-hubble (redshift)
"Compute Hubble parameter for flat ΛCDM."
(let ((omatter (gethash "omatter" cosmo--params))
(H0 (gethash "H0 [Km/s/Mpc]" cosmo--params))
(zp1 (+ 1 redshift)))
(* H0 (sqrt (+ (* omatter (expt zp1 3)) (- 1 omatter))))))
(defun cosmo-hubble ()
"Display Hubble parameter in mini-buffer."
(interactive)
(let ((z (cosmo--read-param "redshift")))
(message (format "%s km/s/Mpc" (cosmo--get-hubble z)))))
(defun cosmo--write-calc (redshift H0 omatter hubble)
"Format and insert cosmological table in buffer."
(insert "Cosmology calculator.\n\n"
"Input Parameters\n"
"----------------\n"
(format "- Redshift: \t%s\n"
redshift)
(format "- Hubble constant, now [km/s/Mpc]:\t%s\n"
H0)
(format "- Matter fractional density, now: \t%s\n"
omatter)
"\n"
"Cosmography at required redshift\n"
"-------------------------------\n"
(format "- Hubble parameter [km/s/Mpc]:\t%s\n"
hubble)))
(defun cosmo-calculator ()
"Compute cosmology and display summary table in a new buffer."
(interactive)
(let* ((redshift (cosmo--read-param "redshift"))
(omatter (gethash "omatter" cosmo--params))
(H0 (gethash "H0 [Km/s/Mpc]" cosmo--params))
(hubble (cosmo--get-hubble redshift)))
(switch-to-buffer-other-window "*cosmo*")
(erase-buffer)
(cosmo--write-calc redshift H0 omatter hubble)
(other-window 1)))
;; Set default values when loading the package
(cosmo-set-default)
(provide 'cosmo)
#+TITLE: cosmo.el
#+AUTHOR: Francesco Montanari
cosmo.el --- Cosmological Calculator
Copyright (C) 2017 Francesco Montanari
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
* Description
This package provides a cosmological calculator integrated into the
Emacs text editor.
Cosmological quantities are computed for a Lambda-CDM model. Such a
framework describes a homogeneous and isotropic universe containing
a cosmological constant (Lambda) and a Cold Dark Matter (CDM)
component, besides ordinary species. The model is characterized by
the following parameters:
- H_0 :: Hubble parameter (expansion rate) today
- Omega_m0 :: Fractional matter density parameter today.
- Omega_Lambda :: Cosmological constant density parameter. At the
moment we consider only flat Lambda-CDM models,
for which =Omega_Lambda = 1 - Omega_m0=.
All cosmological quantities are computed at a given redshift value:
- redshift :: Gravitational redshift of photons frequency due to the
expansion of the Universe.
* Download
The source code can be downloaded from the [[https://gitlab.com/montanari/cosmo-el][git repository page]].
Alternatively, the git repository can be cloned:
#+BEGIN_SRC shell
git clone git@gitlab.com:montanari/cosmo-el.git
#+END_SRC
* Installation
Copy the =cosmo-el= file into your Emacs configuration
directory. E.g., on GNU systems:
#+BEGIN_SRC shell
mkdir ~/.emacs.d/cosmo-el
cp cosmo.el ~/.emacs.d/cosmo-el
#+END_SRC
Open your Emacs configuration file (e.g., =~\/.emacs= on GNU
systems), and add the following lines:
#+BEGIN_SRC emacs-lisp
;; Cosmological calculator
(add-to-list 'load-path "~/.emacs.d/cosmo-el/")
(require 'cosmo)
#+END_SRC
* Usage
Open Emacs and type =M-x cosmo-command=, where the =command= name
varies depending on the desired computation. For example:
- cosmo-set-params :: Set cosmological parameters.
- cosmo-calculator :: Compute cosmology and display summary table in
a new buffer. The following illustrates a possible output:
#+BEGIN_EXAMPLE
Cosmology calculator.
Input Parameters
----------------
- Redshift: 0.1
- Hubble constant, now [km/s/Mpc]: 70
- Matter fractional density, now: 0.3
<...>
Cosmography at required redshift
-------------------------------
- Hubble parameter [km/s/Mpc]: 73.39325582095401
<...>
#+END_EXAMPLE
A complete list of interactive commands can be obtained by typing
=M-x cosmo- TAB=. Documentation is available through =C-h f
cosmo-command=, where =command= should be adapted to the particular
command.
* Support
Bugs and issues are tracked through the [[https://gitlab.com/montanari/cosmo-el][git repository page]]. Please
see [[http://www.chiark.greenend.org.uk/~sgtatham/bugs.html][this page]] about how to report bugs effectively.
* Contributing
/The project is still at an early stage/. Recommendations (and
contributions) aimed to improve the source code are highly
appreciated. New feature suggestions are also welcome, but at this
point priority will be given to reach an idiomatic and extensible
code.
Contributions can be submitted as patches. See [[http://orgmode.org/worg/org-contribute.html#patches][this page]] for an
example of good patches contributions.
More substantial contributions should proceed through git
[[https://git-scm.com/book/en/v2/Distributed-Git-Distributed-Workflows][Integration-Manager Workflow]]. See [[https://www.gnu.org/software/gnuastro/manual/html_node/Contributing-to-Gnuastro.html][this page]] for an example of a
complete working session.
This diff is collapsed.
_____________________
COSMO.EL
Francesco Montanari
_____________________
Table of Contents
_________________
1 Description
2 Download
3 Installation
4 Usage
5 Support
6 Contributing
cosmo.el --- Cosmological Calculator
Copyright (C) 2017 Francesco Montanari
This program is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation, either version 3 of the License, or (at your
option) any later version.
This program is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License along
with this program. If not, see [http://www.gnu.org/licenses/].
1 Description
=============
This package provides a cosmological calculator integrated into the
Emacs text editor.
Cosmological quantities are computed for a Lambda-CDM model. Such a
framework describes a homogeneous and isotropic universe containing a
cosmological constant (Lambda) and a Cold Dark Matter (CDM) component,
besides ordinary species. The model is characterized by the following
parameters:
H_0: Hubble parameter (expansion rate) today
Omega_m0: Fractional matter density parameter today.
Omega_Lambda: Cosmological constant density parameter. At the moment we
consider only flat Lambda-CDM models, for which
`Omega_Lambda = 1 - Omega_m0'.
All cosmological quantities are computed at a given redshift value:
redshift: Gravitational redshift of photons frequency due to the
expansion of the Universe.
2 Download
==========
The source code can be downloaded from the [git repository page].
Alternatively, the git repository can be cloned:
,----
| git clone git@gitlab.com:montanari/cosmo-el.git
`----
[git repository page] https://gitlab.com/montanari/cosmo-el
3 Installation
==============
Copy the `cosmo-el' file into your Emacs configuration
directory. E.g., on GNU systems:
,----
| mkdir ~/.emacs.d/cosmo-el
| cp cosmo.el ~/.emacs.d/cosmo-el
`----
Open your Emacs configuration file (e.g., `~\/.emacs' on GNU systems),
and add the following lines:
,----
| ;; Cosmological calculator
| (add-to-list 'load-path "~/.emacs.d/cosmo-el/")
| (require 'cosmo)
`----
4 Usage
=======
Open Emacs and type `M-x cosmo-command', where the `command' name
varies depending on the desired computation. For example:
cosmo-set-params: Set cosmological parameters.
cosmo-calculator: Compute cosmology and display summary table in a new
buffer. The following illustrates a possible output:
,----
| Cosmology calculator.
|
| Input Parameters
| ----------------
| - Redshift: 0.1
| - Hubble constant, now [km/s/Mpc]: 70
| - Matter fractional density, now: 0.3
| <...>
|
| Cosmography at required redshift
| -------------------------------
| - Hubble parameter [km/s/Mpc]: 73.39325582095401
| <...>
`----
A complete list of interactive commands can be obtained by typing `M-x
cosmo- TAB'. Documentation is available through `C-h f cosmo-command',
where `command' should be adapted to the particular command.
5 Support
=========
Bugs and issues are tracked through the [git repository page]. Please
see [this page] about how to report bugs effectively.
[git repository page] https://gitlab.com/montanari/cosmo-el
[this page] http://www.chiark.greenend.org.uk/~sgtatham/bugs.html
6 Contributing
==============
/The project is still at an early stage/. Recommendations (and
contributions) aimed to improve the source code are highly
appreciated. New feature suggestions are also welcome, but at this
point priority will be given to reach an idiomatic and extensible
code.
Contributions can be submitted as patches. See [this page] for an
example of good patches contributions.
More substantial contributions should proceed through git
[Integration-Manager Workflow]. See [this page] for an example of a
complete working session.
[this page] http://orgmode.org/worg/org-contribute.html#patches
[Integration-Manager Workflow]
https://git-scm.com/book/en/v2/Distributed-Git-Distributed-Workflows
[this page]
https://www.gnu.org/software/gnuastro/manual/html_node/Contributing-to-Gnuastro.html
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment