A four-vane type Radio Frequency Quadrupole (RFQ) is very sensitive to geometrical errors since these may result into mixing of unwanted modes with the desired operating mode. This perturbs the voltage profile of the RFQ, which may deteriorate the beam dynamics, and increase the emittance growth and beam loss. In order to tune the RFQ for a desired voltage profile, a computer program based on transmission line model of RFQ is typically used. Although the theory of tuning program and its experimental validation has been discussed in earlier publications (Palmieri et al., 2010; Sanyasirao, 2014), here we discuss a methodology to perform the tuning of an RFQ in a simulation environment. This approach enables us to do an in-depth analysis of the tuning process, which is illustrated by performing the studies for an example case of the RFQ for the proposed Indian Facility for Spallation Research (IFSR), using the 3D Electro-Magnetic (EM) code CST-MWS. In these simulations, modelling of the vane-tip modulations of the RFQ has been performed in the code CST-MWS, for which a new procedure, using a macro, has been developed, which is presented here. We study perturbation in the voltage profile for two specific situations - first, due to vane-tip modulations, and second, due to misalignment errors. We correct the effect due to each of these perturbations in the simulation environment, using the tuning algorithm, and verify it using the 3D EM code. It has been shown in the paper that the same tuning algorithm with suitable modification can be used also for tuning of the end-cells of RFQ.