Unit_Conversion

The main purpose of this program is to facilitate the conversion between the International System of Units (SI) and the Natural Units (NU).

​ I will briefly explain the methods for converting between unit systems and the definition of initial values, and provide a conversion table from SI to NU units.

Conversion Methods and Initial Values

  • Some initial values defined in the International System of Units (SI) : initvalue first

Based on these initial values, we can start the conversion between different units ;

  • Let’s take the conversion of meters (m) as an example;

    First, we identify the variables related to meters in the initial values and eliminate other variables except for energy:

m1

​ Next, we adjust and simplify the equations to extract the desired units of length :

m2

The final value of 1m in the natural unit system is obtained; using the above method to convert common units, the results are as follows :

  • Conversion tables between the natural system of units and the International System of Units :

conversion

Methods for calling specific functions:

The function is divided into three parts: conversion from NU to SI, conversion from SI to NU, and the search for conversion parameters.

  • The conversion from SI to NU.

where coef_J_to_E = λepsilon0 = εk = kb; hbar = h

x = coef_J_to_E
conversion_dictionary =  \
        {'Joules':1/x,'meter': 3.16304*10**(25)*hbar*c*x,'second':9.48253*10**(33)*hbar*x,\
         'kilogram':8.98752*10**(16)/(x*c**2),'Kelvin':1.38065*10**(-23)/(x*k),\
         'Ampere':1.99347*10**(-16)*math.sqrt(c*epsilon0)/(x*math.sqrt(hbar)),\
         'Coulomb':1.89032*10**(18)*math.sqrt(hbar*c*epsilon0),\
         'Tesla':5.01397*10**(-36)/(x**2*hbar**(3/2)*c**(5/2)*math.sqrt(epsilon0)),\
         'Volt/m':1.67248*10**(-44)/(x**2*hbar**(3/2)*c**(3/2)*math.sqrt(epsilon0)), \
         'momentum':2.99792*10**8/(x*c),'force':3.16152*10**-26/(x**2*hbar*c),\
         'unit charge': 0.302862*math.sqrt(hbar*c*epsilon0)}
  • The conversion from NU to SI.
if conversion_direction == 'LHQCD_to_SI':
    conversion_dictionaryy =  \
    {'TO_Joules':1/conversion_dictionary['Joules'],'TO_meter': 1/conversion_dictionary['meter'],\
     'TO_second':1/conversion_dictionary['second'],'TO_kilogram':1/conversion_dictionary['kilogram'],\
     'TO_Kelvin':1/conversion_dictionary['Kelvin'],'TO_Ampere':1/conversion_dictionary['Ampere'],\
     'TO_Coulomb':1/conversion_dictionary['Coulomb'],'TO_Tesla':1/conversion_dictionary['Tesla'],\
     'TO_Volt/m':1/conversion_dictionary['Volt/m'], 'TO_momentum':1/conversion_dictionary['momentum'],\
     'TO_force':1/conversion_dictionary['force'],'TO_unit charge':1/conversion_dictionary['unit charge']}
    
    return conversion_dictionaryy
  • The selection of conversion parameters.
def determine_coefficient_for_unit_conversion(dt, dx, dx_volume, dp, dp_volume,\
                                              n_max, n_average, v_max, E, B):
    
    print('Searching for proper scaling parameters...')
    print('This may take several minutes.')
    for i in range(-35,35,1):
        hbar = 10**i
        for j in range(9,-9,-1):
            c = 10**j
            for k in range(-30,30,1):
                lambdax = 10**k
                for h in range(-13,13,1):
                    epsilon0 = 10**h
                    
                    try:
                        
                        conversion_table = \
                        unit_conversion('SI_to_LHQCD', coef_J_to_E=lambdax, hbar=hbar, c=c, k=1., epsilon0=epsilon0)
                        
                        dt_converted = dt*conversion_table['second']
                        dx_converted = dx*conversion_table['meter']
                        dp_converted = dp*conversion_table['momentum']
                        dx_volum_converted = dx_volume*conversion_table['meter']**3
                        dp_volume_converted = dp_volume*conversion_table['momentum']**3    
                        
                        f_max_converted = n_max/(dx_volum_converted*dp_volume_converted)                        
                        unit_charge_converted = 1.6*10**(-19)*conversion_table['Coulomb']
                        v_max_converted = v_max*conversion_table['meter']/conversion_table['second']
                        
                        rho_max_converted = unit_charge_converted*\
                                            n_average/dx_volum_converted
                        J_max_converted = rho_max_converted*v_max_converted                       
                        
                        E_coef_converted = 1/(4*math.pi*epsilon0)*rho_max_converted*dx +\
                                           E*conversion_table['Volt/m']
                        
                        B_coef_converted = 1/(4*math.pi*epsilon0*c**2)*J_max_converted*dx+\
                                           B*conversion_table['Tesla']
                        F_converted = unit_charge_converted*(E_coef_converted+v_max_converted*B_coef_converted)
                        
                        
                        if 10**(-10)<abs(E_coef_converted)<10**10 and\
                           10**(-10)<abs(B_coef_converted)<10**10 and\
                           10**(-10)<(1/dt_converted)<10**10 and \
                           10**(-10)<abs((F_converted/dp_converted)<10**10 and \
                           10**(-10)<(v_max_converted/dx_converted))<10**10 and \
                           10**(-5)<rho_max_converted<10**5 and \
                           10**(-5)<J_max_converted<10**5 and\
                           10**(-10)<f_max_converted<10**10:
                            return hbar, c, lambdax, epsilon0
                    
                    except: pass

results matching ""

    No results matching ""