Feeds:
Posts
Comments

Posts Tagged ‘Physics’


After installing CalcHEP (see this post), oen should go to the working directory created by CalcHEP and running the program,

 $ cd ~/Documents/WorkCalcHEP
 $ ./calchep
Calling the program.

Calling the program.

Then the CalcHEP shell will appear, and you can choose your model (in future posts I’ll tell you the easiest way to create and import models)

List of Models included in CalcHEP

List of Models included in CalcHEP

Once you have picked a model, you can enter a process

Possibilities after choosing the model

Possibilities after choosing the model

The list of particles in the model you have chosen is shown, and you can write the process you want to study. Note that diagrams with certain particles can be excluded, but in this example I didn’t.

Entering the process on the shell

Entering the process on the shell

Resulting in,

Result of the entered (sub)process

Result of the entered (sub)process

CalcHEP can draw the Feynman diagrams of a certain (sub)process,

Feynman diagrams of the subprocess

Feynman diagrams of the subprocess

and after squaring the amplitude,

Squaring the (sub)process amplitude

Squaring the (sub)process amplitude

you can see the “squared Feynman diagrams” 🙂 Cool, Isn’t it?

Squared Feynman diagrams of the (sub)process

Squared Feynman diagrams of the (sub)process

In a future post I shall write about the numerical integration, or the possibility of exporting plots and Feynman diagrams to LaTeX 😀

Cheers.

Read Full Post »


In order to install CalcHEP, one needs to download the code and to compile it.

The code can be found at http://theory.sinp.msu.ru/~pukhov/calchep.html, as usual it is recommended to download the current version, unless a major pre-requisite problem is in sight.

Calhep-html

It is useful to install some packages before start compiling CalcHEP

 $ sudo apt-get install cernlib gfortran xlibx11-dev

Then, go to the folder where CalcHEP was downloaded and decompress it,

 $ tar -xzf calchep_3.4.cpc.tgz

Now, move to the calchep_3.4.cpc folder and compile the code

 $ cd calchep.3.4.cpc
 $ make

If the code has compiled without errors, it is enough to start working. However, usually it is recommended to do a couple of extra things.

Creating a Working folder

The default work directory is

 $CALCHEP/work/

, but in general it is a good idea to have an independent “work folder”, in order for doing so, in the CalcHEP directory there is a script to create that folder… it is called mkUsrDir and admits one argument (the path to the folder you want to create)

 $ ./mkUsrDir ~/Documents/WorkCalcHEP

Once created the working directory, you can move there and call the CalcHEP console (assuming the directory created above I would do the following)

 $ cd ~/Documents/WorkCalcHEP
 $ ./calchep

and you get this:calchep-console

Now, you are ready to start working!

Read Full Post »


This post is more about a personal opinion.

Most of the followers of my blog know that I’m a devote Linux user, and that I prefer Open Source than any other software.

It is clear than most business people prefer to spend money for a piece of software which get the job done. And additionally, developers will align with the mainstream vendor… or in some cases, money convince them.

The last to months I’ve been working in some supergravity theory, and you might imagine that even a easy calculation is messy… at least, and will take a huge amount of time to complete.

On the other hand Mathematica offers a huge (really huge) toolkit for mathematicians, physicists, economists, and so on. I admit it… I sort of hate to use Mathematica, really do!, but although we all know is amazing as a toolkit.

Nonetheless, most scientist (specially those who grow up using this kind of software), trust the results as if it was not possible to be wrong!!! But if you look further…. there is a book, as enormous as Mathematica user’s guide, of bugs :-S

A year ago one of my office mate found two bugs: one in an integration routine, and another in a loop routine!!!! A LOOP ROUTINE… Do you know someone who has never used a loop routine? How many possible errors have been publish and propagated?! Moreover, I found a bug myself… in the plot function 😐

Since then I use SAGE… or Python, so I’ve spent a lot of time learning, developing and proving routines, asking in the help channels and so on!

I know that this alternatives are far away from Mathematica or Maple or whatever your favourite calculation software is… but imagine!

Today I found a Mathematica package for computing GR tensors, you can use differential forms, first order formalism, redefine quantities in term of vielbeins, write equations using differential forms (with Hodge star and so on)… Incredible! Isn’t it?

Who develop this package? It was not Wolfram!!!! If I were the developer of this marvelous package, I’d prefer to kill myself before writing such a thing for a product which is not available for everyone. Exaggeration?! yes, may be… but I’m citizen of a wealth country, full of poor people. Yes, I also know that any pirate page has a cracked copy of Mathematica… but why should I crack a program?

I don’t want to crack Mathematica… I want an open source software which do as Mathematica. Sorry, I correct: I want an open source software which do BETTER than Mathematica.

My bet is on SAGE, and that’s why I’m willing to contribute with this project.

Live wide and prosper! Enjoy!

Dox

Read Full Post »


This code is supposed to be (if some one does the work in the future) located in sage.tensor.differential_form_element.

The code presented below is a slight modification of Joris code for differential forms manipulation on SAGE.

Needed modules

from sage.symbolic.ring import SymbolicRing, SR
from sage.rings.ring_element import RingElement
from sage.algebras.algebra_element import AlgebraElement
from sage.rings.integer import Integer
from sage.combinat.permutation import Permutation

The advantage of using this is that, tensors defined here are an Algebra element, not just a python object as in the previous code.

The sage.combinat.permutation won’t be used (yet), but could be useful if tensor symmetries are defined.

TensorFormatter

class TensorFormatter:
    r"""
    This class contains all the functionality to print a tensor in a
    graphically pleasing way.  This class is called by the ``_latex_`` and
    ``_repr_`` methods of the Tensor class.
    """
    def __init__(self, space):
        r"""
        Construct a tensor formatter.  See
        ``TensorFormatter`` for more information.
        """
        self._space = space

    def repr(self, comp, fun):
        r"""
        String representation of a primitive tensor, i.e. a function
        times a tensor product of d's of the coordinate functions.

        INPUT:

        - ``comp`` -- a subscript of a differential form.

        - ``fun`` -- the component function of this form.

        EXAMPLES::

            sage: from sage.tensor.tensor_element import TensorFormatter
            sage: x, y, z = var('x, y, z')
            sage: U = CoordinatePatch((x, y, z))
            sage: D = TensorFormatter(U)
            sage: D.repr((0, 1), z^3)
            'z^3*dx@dy'

        """

        str = "@".join( \
            [('d%s' % self._space.coordinate(c).__repr__()) for c in comp])

        if fun == 1 and len(comp) > 0:
            # We have a non-trivial form whose component function is 1,
            # so we just return the formatted form part and ignore the 1.
            return str
        else:
            funstr = fun._repr_()

            if not self._is_atomic(funstr):
                funstr = '(' + funstr + ')'

            if len(str) > 0:
                return funstr + "*" + str
            else:
                return funstr

    def latex(self, comp, fun):
        r"""
        Latex representation of a primitive differential form, i.e. a function
        times a tensor product of d's of the coordinate functions.

        INPUT:

        - ``comp`` -- a subscript of a differential form.

        - ``fun`` -- the component function of this form.

        EXAMPLES::

            sage: from sage.tensor.tensor_element import TensorFormatter
            sage: x, y, z = var('x, y, z')
            sage: U = CoordinatePatch((x, y, z))
            sage: D = TensorFormatter(U)
            sage: D.latex((0, 1), z^3)
            'z^{3} d x \otimes d y'

        """

        from sage.misc.latex import latex

        str = " \otimes ".join( \
            [('d %s' % latex(self._space.coordinate(c))) for c in comp])

        if fun == 1 and len(comp) > 0:
            return str
        else:
            funstr = latex(fun)

            if not self._is_atomic(funstr):
                funstr = '(' + funstr + ')'

            return funstr + " " + str

    def _is_atomic(self, str):
        r"""
        Helper function to check whether a given string expression
        is atomic.

        EXAMPLES::

            sage: x, y, z = var('x, y, z')
            sage: U = CoordinatePatch((x, y, z))
            sage: from sage.tensor.tensor_element import TensorFormatter
            sage: D = TensorFormatter(U)
            sage: D._is_atomic('a + b')
            False
            sage: D._is_atomic('(a + b)')
            True
        """
        level = 0
        for n, c in enumerate(str):
            if c == '(':
                level += 1
            elif c == ')':
                level -= 1

            if c == '+' or c == '-':
                if level == 0 and n > 0:
                    return False
        return True

The only I’ve changed here is “DifferentialForm” by “Tensor” and “\wedge” by “\otimes”

The above code allows to write the tensor product in a basis, dx^1\otimes\cdots\otimes dx^n. The chosen symbol for denoting the tensor product was @.

Tensor Class

This code is incomplete due to:

  • I’ve not defined the TensorsAlgebra, which should be done in parallel.
  • There are a lot of attributes not presented in this class.
  • class Tensor(AlgebraElement):
        r"""
        Tensor class.
        """
    
        def __init__(self, parent, degree, fun = None):
            r"""
            Construct a tensor.
    
            INPUT:
    
            - ``parent`` -- Parent algebra of tensors.
    
            - ``degree`` -- Degree of the tensor.
    
            - ``fun`` (default: None) -- Initialize this differential form with the given function.  If the degree is not zero, this argument is silently ignored.
    
            EXAMPLES::
    
                sage: x, y, z = var('x, y, z')
                sage: F = Tensors(); F
                Algebra of tensors in the variables x, y, z
                sage: f = Tensor(F, 0, sin(z)); f
                sin(z)
    
            """
    
            from sage.tensor.tensorss import Tensors
            if not isinstance(parent, Tensors):
                raise TypeError, "Parent not an algebra of tensors."
    
            RingElement.__init__(self, parent)
    
            self._degree = degree
            self._components = {}
    
            if degree == 0 and fun is not None:
                self.__setitem__([], fun)
    
        def __getitem__(self, subscript):
            r"""
            Return a given component of the tensor.
    
            INPUT:
    
            - ``subscript``: subscript of the component.  Must be an integer
            or a list of integers.
    
            EXAMPLES::
    
                sage: x, y, z = var('x, y, z')
                sage: F = Tensors(); F
                Algebra of tensors in the variables x, y, z
                sage: f = Tensor(F, 0, sin(x*y)); f
                sin(x*y)
                sage: f[()]
                sin(x*y)
            """
    
            if isinstance(subscript, (Integer, int)):
                subscript = (subscript, )
            else:
                subscript = tuple(subscript)
    
            dim = self.parent().base_space().dim()
            if any([s >= dim for s in subscript]):
                raise ValueError, "Index out of bounds."
    
            if len(subscript) != self._degree:
                raise TypeError, "%s is not a subscript of degree %s" %\
                    (subscript, self._degree)
    
            """sign, subscript = sort_subscript(subscript)"""
    
            if subscript in self._components:
                return sign*self._components[subscript]
            else:
                return 0
    
        def __setitem__(self, subscript, fun):
            r"""
            Modify a given component of the tensor.
    
            INPUT:
    
            - ``subscript``: subscript of the component.  Must be an integer or a list of integers.
    
            EXAMPLES::
    
                sage: F = Tensors(); F
                Algebra of tensors in the variables x, y, z
                sage: f = Tensor(F, 2)
                sage: f[1, 2] = x; f
                x*dy@dz
            """
    
            if isinstance(subscript, (Integer, int)):
                subscript = (subscript, )
            else:
                subscript = tuple(subscript)
    
            dim = self.parent().base_space().dim()
            if any([s >= dim for s in subscript]):
                raise ValueError, "Index out of bounds."
    
            if len(subscript) != self._degree:
                raise TypeError, "%s is not a subscript of degree %s" %\
                    (subscript, self._degree)
    
            """sign, subscript = sort_subscript(subscript)"""
            self._components[subscript] = SR(fun)

    Ok, so again I’ve changed “DifferentialForm(s)” by “Tensor(s)”, drop the permutation of indices (’cause tensors do not need to be neither symmetric nor anti-symmetric.

    I’ll keep working with this code… It’s all by now. Oh! I’ll post next week the rest of the code based in Sergey’s GRPy.

    Enjoy.

    Dox

    Read Full Post »


    I’ve just updated the SAGE worksheet which uses the definitions described in the previous posts.

  • There are some explanations in text format
  • The code has been hidden… because is long.
  • Moreover… I’ve discover something really amazing! Joris Vankerschaver‘s code of the differential form package in SAGE. Thus, I could use some ideas from Joris’ code to improve GRmodule. Nice, Isn’t it?

    Let’s hope I could so something nice this weekend!

    Don’t forget check the worksheet, and post some comment for feedback! 😉

    Enjoy!

    Dox

    Read Full Post »


    As I wrote last week I think, I’m teaching Modern Physics at the Catholic University of Valparaiso.

    Since I’m a LaTeX lover and a prolific writer (just science b.t.w.), just decide to prepare some lecture notes of the course (in Spanish) for my students… and for producing the pictures I’m using the matplotlib module of Python.

    BB-radiance

    import numpy as np
    import matplotlib.pyplot as plt

    x = np.arange(0.,5.,0.001)
    y = 1.0/np.sqrt(1- x**2)

    plt.plot(x, x**2/2.0, ‘r–‘, x, x**3/(np.exp(2*x)-1), ‘b’)
    plt.suptitle(r’Radiancia Espectral’, fontsize = 25)
    plt.axis([0,5,0,0.4])
    plt.ylabel(r’$\mathcal{R}(\nu)$’, fontsize = 15)
    plt.xlabel(r’Frecuencia $\nu$’, fontsize = 15)

    plt.annotate(‘Teoria Clasica’, xy=(1, 0.35), xytext=(1.6, 0.35), \ arrowprops = dict(facecolor = ‘red’, shrink=0.1))
    plt.annotate(‘Experimento’, xy=(2, 0.15), xytext=(2.4, 0.25),\ arrowprops = dict(facecolor = ‘blue’, shrink=0.1))

    plt.show()

    BB-varius

    import numpy as np
    import matplotlib.pyplot as plt

    x = np.arange(0.,15.,0.001)

    plt.plot(x, x**3/(np.exp(2*x)-1), ‘r’, x, x**3/(np.exp(x)-1), ‘b’, x,\ x**3/(np.exp(2*x/3.0)-1), ‘g’)
    plt.suptitle(r’Radiancia Espectral’, fontsize = 25)
    plt.axis([0,15,0,5])
    plt.ylabel(r’$\mathcal{R}(\nu)$’, fontsize = 15)
    plt.xlabel(r’Frecuencia $\nu$’, fontsize = 15)

    plt.annotate(“”, xy=(1.41396, 0.17766), xytext=(1.41396, 0.),\ arrowprops=dict(arrowstyle=”-“, connectionstyle=”arc3”))
    plt.annotate(“”, xy=(2.82534, 1.42151), xytext=(2.82534, 0.),\ arrowprops=dict(arrowstyle=”-“, connectionstyle=”arc3”))
    plt.annotate(“”, xy=(4.23398, 4.79732), xytext=(4.23398, 0.),\ arrowprops=dict(arrowstyle=”-“, connectionstyle=”arc3”))

    plt.annotate(r’$T$’, xy=(2, 0.15), xytext=(2.4, 0.65),\ arrowprops=dict(facecolor = ‘red’, shrink=0.1))
    plt.annotate(r’$2T$’, xy=(4, 1.45), xytext=(5, 2.),\ arrowprops=dict(facecolor = ‘blue’, shrink=0.1))
    plt.annotate(r’$3T$’, xy=(7.24, 4.15), xytext=(8.5, 4.5),\ arrowprops = dict(facecolor = ‘green’, shrink=0.1))

    plt.show()

    Those are the final pictures I include in the notes, which are updated at least once a week at the google group page.

    Read Full Post »


    From March I’ve been dictating a couple of courses at the Catholic University of Valparaiso, one of basic electromagnetism, and other about modern physics.

    With the students of Modern Physics agree to communicate via a Google Group. So if you are interested, you might follow the discussions (in Spanish) at Fisica Moderna – PUCV group.

    Read Full Post »