Force component in particle body force

Raheem Sterling_22160
Raheem Sterling_22160 Altair Community Member
edited October 2023 in Community Q&A

Hi,

I want to convert the total force of particles in the x-direction into a certain value, and add a value to the total forces in the y and z directions. So I did some changes in PBF as below:

double a=1.0;

results.force.setX(a); //set force in x direction as zero.

results.force.setY(results.force.getY()+a); //set force in y direction as +=a.

results.force.setZ(results.force.getZ()+a); //set force in z direction as +=a.

However, the results were the same for all three cases, with the particles experiencing a constant force of 'a'.

Because the functionality I want to achieve in the x-direction is "=", and the functionality I want to implement in the y and z directions is "+=".

Thanks

Tagged:

Answers

  • Stephen Cole
    Stephen Cole
    Altair Employee
    edited October 2023

    Hi Raheem,

    Looks like a typo in that lines 3 and 4 should be set and get Y and Z, both currently X:

    results.force.setX(results.force.getX()+a); //set force in y direction as +=a.

    results.force.setX(results.force.getX()+a); //set force in z direction as +=a.

    Otherwise I'd expect that to work ok,.


    Regards

    Stephen

     

  • Raheem Sterling_22160
    Raheem Sterling_22160 Altair Community Member
    edited October 2023

    Hi Raheem,

    Looks like a typo in that lines 3 and 4 should be set and get Y and Z, both currently X:

    results.force.setX(results.force.getX()+a); //set force in y direction as +=a.

    results.force.setX(results.force.getX()+a); //set force in z direction as +=a.

    Otherwise I'd expect that to work ok,.


    Regards

    Stephen

     

    Sorry, I made a written mistake in the question and revised, it should be:

    double a=1.0;

    results.force.setX(a); //set force in x direction as zero.

    results.force.setY(results.force.getX()+a); //set force in y direction as +=a.

    results.force.setZ(results.force.getX()+a); //set force in z direction as +=a.

    But it wasn't right. Then I debug the system line by line as below, it seems like "tmp3" wasn't assgined the value of results.force.getX(). I still can't fixed the problem.

    image

    image

     

Welcome!

It looks like you're new here. Sign in or register to get started.

Welcome!

It looks like you're new here. Sign in or register to get started.