udcm-su / NTMpy

Simulation of multi temperature and multi layer heat diffusion
http://udcm.fysik.su.se/code
MIT License
18 stars 11 forks source link

get the variation of source term #28

Open karnapravin opened 1 year ago

karnapravin commented 1 year ago

How do I get the values of the source term at each time and position, like for electron or lattice temperature? I need to get the source term values to calculate the contribution of -(Ke/G del^2Te). Thanks

karnapravin commented 1 year ago

Also, I cannot visualize the source term even if I copy the code from the example page. The error page is a huge page but at last it says" AssertionError: Pieces mismatches: [{1768, 1769}, {1776, 1775}, {1784, 1783}] ". Also the animation does not run. My code for solving TTM is as follows. from NTMpy import NTMpy as ntm from matplotlib import pyplot as plt import numpy as np import numericalunits as u u.reset_units('SI') s = ntm.source() s.spaceprofile = "TMM" s.timeprofile = "Gaussian" s.FWHM = 0.1u.ps #Full width half max of the laser pulse s.fluence = 17u.mJ/u.cm*2 #Fluence of the laser s.t0 = 1u.ps #Time when Gaussian peaks s.lambda_vac = 400 #Wavelength of incident light (in nm!) s.theta_in = np.pi/4 #Incident angle s.polarization = "p"

copper

length_cu = 500u.nm #Length of the Material n_cu = 1.2878+2.2596j #Complex refractive index k_el_cu = 391u.W/(u.mu.K);#Heat conductivity k_ph_cu = 7u.W/(u.mu.K);#Heat conductivity rho_cu = 1e38.96*u.kg/(u.m3)#Density C_el_cu = lambda Te:(96.8*u.J/(u.m*3u.K2))/(1e38.96u.kg/(u.m3)) Te #Electron heat capacity C_lat_cu = 3.62e6u.J/(u.m3*u.K*2)/rho_cu #Lattice heat capacity G_cu = 6e17u.W/(u.m*3u.K) #Lattice electron coupling constant Temperature Model:

Two temperatures are considered, electron and lattice

sim = ntm.simulation(2,s)

add parameters for both layers and both systems

sim.addLayer(length_cu,n_cu,[k_el_cu,k_ph_cu],[C_el_cu,C_lat_cu],rho_cu,[G_cu])

sim.addLayer(length_ta,n_ta,[k_el_ta,k_ph_ta],[C_el_ta,C_lat_ta],rho_ta,G_ta)

sim.final_time = 15*u.ps

To get the raw output

[x,t,T] = sim.run()

Visualize result

Create a visual object where the simulation gets passed on

v = ntm.visual(sim)

output of v.source is the full matrix of the source(x,t)

so = v.source()

A contourplot of the electron system

v.contour('1')

This will only work in the two temperature case.

v.contour('2') [timegrid, avT] = v.average()

animate the result input parameter is the speed of the animation

speed = 1 v.animation(speed)

VaSca92 commented 1 year ago

Ciao karnapravin

You can get the source term with the method sourceprofile() of the class simulation.

For example, you can run S = sim.sourceprofile('TMM','Gaussian', x, L, t, 12)

where

-12 is the number of points where the diffusion equation is imposed, in the current version of the code must be 12

For the problems with the plot tools, I am not sure what is the cause. May I ask what IDE and interpreter are you using? (so I can try to reproduce the same error)

If I take a long time to respond, you can email me at valentino.scalera@cern.ch (for some reason the repository owners did not received any notification of the issue form github)