Skip to content

Commit

Permalink
modified access of functions in c_NEGF_Common<T>
Browse files Browse the repository at this point in the history
  • Loading branch information
saurabh-s-sawant committed Dec 7, 2024
1 parent c9da891 commit 49a16e9
Show file tree
Hide file tree
Showing 2 changed files with 87 additions and 92 deletions.
166 changes: 86 additions & 80 deletions Source/Solver/Transport/NEGF/NEGF_Common.H
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,12 @@ class c_NEGF_Common : protected MatrixBlock<T>, private c_IntegrationPath
amrex::Gpu::HostVector<amrex::Real> h_Trace_r;
amrex::Gpu::HostVector<amrex::Real> h_Trace_i;

/*MPI Params*/
amrex::Vector<int> MPI_recv_count;
amrex::Vector<int> MPI_recv_disp;
amrex::Vector<int> MPI_send_count;
amrex::Vector<int> MPI_send_disp;

#ifdef AMREX_USE_GPU
BlkTable1D d_Alpha_loc_data;
BlkTable1D d_Xtil_glo_data;
Expand Down Expand Up @@ -288,45 +294,23 @@ class c_NEGF_Common : protected MatrixBlock<T>, private c_IntegrationPath
template <typename U>
void Print_Table2D_loc(const U &Tab2D_data);

// AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE
// MatrixBlock<T> get_Gamma(const MatrixBlock<T>& Sigma);
void set_Contact_Electrochemical_Potential(
const amrex::Vector<amrex::Real> &ep);

protected:
virtual void Define_FileHeaderForCurrent();
virtual void Read_MaterialSpecificNanostructureProperties() = 0;
virtual void Set_MaterialSpecificParameters() = 0;
virtual int Compute_NumAtoms() = 0;
virtual int Compute_AtomsPerUnitcell() = 0;
virtual int Compute_NumFieldSites() = 0;
virtual int Compute_NumAtomsPerFieldSite() = 0;
virtual int Set_PrimaryTransportDir() = 0;
virtual int Set_AverageFieldFlag() = 0;
virtual int Compute_NumAtomsToAvgOver() { return 1; }
virtual void Set_BlockDegeneracyVector(amrex::Vector<int> &vec) = 0;
virtual void Print_MaterialSpecificReadData() = 0;
virtual int get_Hsize() = 0;
virtual int get_offDiag_repeatBlkSize() = 0;
virtual void Define_MPI_BlkType() = 0;
void Set_TerminalBiasesAndContactPotential();

virtual void Construct_Hamiltonian() = 0;
virtual void Define_ContactInfo() = 0;
/*define the following in overridden Define_ContactInfo:
*global_contact_index
*contact_transmission_index
*h_tau
*/
void Write_Data(const std::string filename_prefix,
const RealTable1D &n_curr_out_data,
const RealTable1D &Norm_data);

virtual void Define_EnergyLimits();
virtual void Define_IntegrationPaths();
void Write_InputInducedCharge(const std::string filename_prefix,
const RealTable1D &n_curr_in_data);

virtual AMREX_GPU_HOST_DEVICE void Compute_SurfaceGreensFunction(
MatrixBlock<T> &gr, const ComplexType EmU) = 0;
void Write_Current(const int step,
const int total_iterations_in_step,
const amrex::Real avg_intg_pts);

virtual void Write_Eql_Characteristics(
const amrex::Vector<ComplexType> E_vec, const RealTable1D &DOS_data,
const RealTable1D &Transmission_data,
const RealTable1D &Conductance_data, std::string filename);
virtual void Define_PotentialProfile();
protected:

/*MPI params*/
int my_rank = 0;
Expand Down Expand Up @@ -465,102 +449,105 @@ class c_NEGF_Common : protected MatrixBlock<T>, private c_IntegrationPath
RealTable1D d_NonEq_Integrand_Drain_data;
#endif

public:
/*MPI Params*/
amrex::Vector<int> MPI_recv_count;
amrex::Vector<int> MPI_recv_disp;
amrex::Vector<int> MPI_send_count;
amrex::Vector<int> MPI_send_disp;
// virtual methods
virtual void Read_MaterialSpecificNanostructureProperties() = 0;
virtual void Set_MaterialSpecificParameters() = 0;
virtual int Compute_NumAtoms() = 0;
virtual int Compute_AtomsPerUnitcell() = 0;
virtual int Compute_NumFieldSites() = 0;
virtual int Compute_NumAtomsPerFieldSite() = 0;
virtual int Set_PrimaryTransportDir() = 0;
virtual int Set_AverageFieldFlag() = 0;
virtual int Compute_NumAtomsToAvgOver() { return 1; }
virtual void Set_BlockDegeneracyVector(amrex::Vector<int> &vec) = 0;
virtual void Print_MaterialSpecificReadData() = 0;
virtual int get_Hsize() = 0;
virtual int get_offDiag_repeatBlkSize() = 0;
virtual void Define_MPI_BlkType() = 0;

virtual ~c_NEGF_Common() = default;
virtual void Construct_Hamiltonian() = 0;

void Initialize_NEGF_Params(const std::string &NS_name_str,
const int &NS_id_counter,
const amrex::Real &NS_initial_deposit_value,
const std::string &negf_foldername_str);
void Define_MPISendCountAndDisp();
void Initialize_ChargeAtFieldSites();
/*define the following in overridden Define_ContactInfo:
*global_contact_index
*contact_transmission_index
*h_tau
*/
virtual void Define_ContactInfo() = 0;

virtual void Generate_AtomLocations(amrex::Vector<s_Position3D> &pos) = 0;
virtual AMREX_GPU_HOST_DEVICE void Compute_SurfaceGreensFunction(
MatrixBlock<T> &gr, const ComplexType EmU) = 0;

void Initialize_NEGF(const std::string common_foldername_str,
const bool _use_electrostatics);

void Initialize_GPUArraysForGreensAndSpectralFunctionToZero();
void Initialize_GPUArraysForChargeComputationToZero();
virtual void Define_FileHeaderForCurrent();
virtual void Define_EnergyLimits();
virtual void Define_IntegrationPaths();
virtual void Write_Eql_Characteristics(
const amrex::Vector<ComplexType> E_vec, const RealTable1D &DOS_data,
const RealTable1D &Transmission_data,
const RealTable1D &Conductance_data, std::string filename);
virtual void Define_PotentialProfile();

void Set_TerminalBiasesAndContactPotential();
// other methods accessed from derived classes
void Solve_NEGF(RealTable1D &n_curr_out_data, const int iter,
const bool flag_update_terminal_bias);

void Compute_InducedCharge(RealTable1D &n_curr_out_data);
void Compute_Rho0();
void Compute_RhoEq();
void Compute_RhoNonEq();
void Compute_RhoNonEqOld();
void Compute_GR_atPoles();
void Compute_Current();
void Compute_DensityOfStates(std::string DOS_foldername,
bool flag_write_LDOS);
void Compute_DensityOfStates_General(bool isIter, int iter_or_step);

void Copy_LocalChargeFromNanostructure(RealTable1D &container_data,
const int NS_offset);

void Copy_BroydenPredictedCharge(const RealTable1D& h_n_curr_in_data);

void Compute_DensityOfStates_General(bool isIter, int iter_or_step);

void Write_Data_General(const bool isIter,
const int iter_or_step,
const int total_iterations_in_step,
const amrex::Real avg_intg_pts,
RealTable1D const& h_n_curr_out_data,
RealTable1D const& h_Norm_data);

void Write_Data(const std::string filename_prefix,
const RealTable1D &n_curr_out_data,
const RealTable1D &Norm_data);
void Initialize_NEGF_Params(const std::string &NS_name_str,
const int &NS_id_counter,
const amrex::Real &NS_initial_deposit_value,
const std::string &negf_foldername_str);

void Write_InputInducedCharge(const std::string filename_prefix,
const RealTable1D &n_curr_in_data);
void Define_MPISendCountAndDisp();

void Write_Current(const int step,
const int total_iterations_in_step,
const amrex::Real avg_intg_pts);
void Initialize_ChargeAtFieldSites();

// setters/getters for MPI params
void Initialize_NEGF(const std::string common_foldername_str,
const bool _use_electrostatics);

/* setters/getters */
// for MPI params
void set_num_field_sites_loc_NS_offset(int val)
{ num_field_sites_loc_NS_offset = val; }

// setters/getters for nanostructure params
// for nanostructure params
int get_NS_Id() const { return NS_Id; }
int get_num_field_sites() const { return num_field_sites; }
int get_num_field_sites_loc() const { return blkCol_size_loc; }
amrex::Real get_Fermi_level() const { return E_f; }

// setters/getters for contact params
// for contact params
int get_Vds() const { return Vds; }
int get_Vgs() const { return Vgs; }
std::string get_Gate_String() const { return Gate_String; }
bool is_contact_mu_specified() const { return flag_contact_mu_specified; }
void set_Contact_Electrochemical_Potential(
const amrex::Vector<amrex::Real> &ep);

virtual amrex::Real get_Source_Electrochemical_Potential() const
{
return Contact_Electrochemical_Potential[0];
}

virtual amrex::Real get_Drain_Electrochemical_Potential() const
{
return Contact_Electrochemical_Potential[NUM_CONTACTS - 1];
}

const std::string *get_Contact_Parser_String() const
{
return Contact_Parser_String;
}

// setters/getters for output params
// for output params
void Set_StepFilenameString(const int step);
void Set_IterationFilenameString(const int iter);
int get_flag_write_at_iter() const { return write_at_iter; }
Expand All @@ -570,7 +557,26 @@ class c_NEGF_Common : protected MatrixBlock<T>, private c_IntegrationPath
std::string get_iter_foldername() const { return iter_foldername_str; }
std::string get_read_atom_filename() const { return read_atom_filename; }

// for negf specific output
int get_Total_Integration_Pts() const;

public:

virtual ~c_NEGF_Common() = default;

void Compute_InducedCharge(RealTable1D &n_curr_out_data);
void Compute_Rho0();
void Compute_RhoEq();
void Compute_RhoNonEq();
void Compute_RhoNonEqOld();
void Compute_GR_atPoles();
void Compute_Current();
void Compute_DensityOfStates(std::string DOS_foldername,
bool flag_write_LDOS);

void Initialize_GPUArraysForGreensAndSpectralFunctionToZero();
void Initialize_GPUArraysForChargeComputationToZero();

};

template <typename T>
Expand Down
13 changes: 1 addition & 12 deletions Source/Solver/Transport/NEGF/NEGF_Common.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1399,17 +1399,6 @@ void c_NEGF_Common<T>::Write_Data(const std::string filename_prefix,
}
}

// template<typename T>
// void
// c_NEGF_Common<T>::Define_ContactInfo ()
//{
// /*define the following in overridden functions:
// *global_contact_index
// *contact_transmission_index
// *h_tau
// */
// }

template <typename T>
void c_NEGF_Common<T>::Allocate_ArraysForHamiltonian()
{
Expand Down Expand Up @@ -4705,7 +4694,7 @@ void c_NEGF_Common<T>:: Set_TerminalBiasesAndContactPotential()
auto &rGprop = rCode.get_GeometryProperties();
auto &rBC = rCode.get_BoundaryConditions();

if (!is_contact_mu_specified())
if (!flag_contact_mu_specified)
{
amrex::Real V_contact[NUM_CONTACTS] = {0., 0.};
amrex::Vector<amrex::Real> ep(NUM_CONTACTS, 0);
Expand Down

0 comments on commit 49a16e9

Please sign in to comment.